From xemacs-m  Sat Apr 19 04:30:58 1997
Received: from bittersweet.inetarena.com (karlheg@bittersweet.inetarena.com [206.129.216.38])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id EAA19843
	for <xemacs-beta@xemacs.org>; Sat, 19 Apr 1997 04:30:33 -0500 (CDT)
Received: (from karlheg@localhost)
	by bittersweet.inetarena.com (8.8.5/8.8.5) id CAA17987;
	Sat, 19 Apr 1997 02:32:07 -0700
Date: Sat, 19 Apr 1997 02:32:07 -0700
Message-Id: <199704190932.CAA17987@bittersweet.inetarena.com>
From: "Karl M. Hegbloom" <karlheg@inetarena.com>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="8nn+M+O7ej"
Content-Transfer-Encoding: 7bit
To: <xemacs-beta@xemacs.org>
Subject: compface patches for xbm->xface from exmh package
X-Mailer: VM 6.27 under 20.1 XEmacs Lucid
X-Face: /Q}=yl}1_v7nP)xXo5XjG8+tl@=uVu7o5u6)f]zN?+<hB!K.m9:[|*p34jVN`O;:XZXVSy>/\R>qDt(t8w!-i{(y0"`jFw^uk8inzO9wXabd'CdjUWfC\GHi:6nO*YC89#-qD>Q4r%9!V"<RYJ=7D#$";q=zML5'!=wvXk^$`6FT=5CMofQX)WUKt0p:OKl.mFOXx/D


--8nn+M+O7ej
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit


 I pulled these out of the exmh package at
             <URL:ftp://ftp.cs.indiana.edu/pub/faces/exmh/>

 I hope it's not considered inappropriate to post this to the list...

 The licence in the exmh package didn't seem to want to restrict this.

 Perhaps they can be integrated into the version of compface
distributed at the XEmacs ftp site?  That might make it easier on
people. The Debian GNU/Linux version of compface already incorporates
this patch; it works well.
 

--8nn+M+O7ej
Content-Type: text/plain
Content-Description: compface.README
Content-Disposition: inline;
	filename="compface.README"
Content-Transfer-Encoding: 7bit

The compface.patch file has a patch that teaches the compface
and uncompface programs how to read .xbm format (X bitmap) files,
instead of the arcane .ikon files it used before.

This patch should apply OK to the files in the compface directory of
the picons (a.k.a. facesaver) software.

With the new version of uncompface, the exmh X-Face pipeline can just be:
uncompface -X

To create the X-Face header from a 48x48 .xbm file, just do
compface your.xbm > out

The file "out" will contain three lines of jibberish. You need to add
the X-Face: header

e.g. out contains:
 znu_@QbSegynS/\2YND%-w_L.V$bG-M.}<:^^3tS,BszwEdNEo)-/"eZF^+1]M%>A#"QV8U
 #*cFsKsnwC63B`<ee|ik?J'%flkca.~y"QRpTa~0*U~-A2$*bF<OCR3NNl9f8Th79*RvU$D?EsWPU0
 _"Tj_BHv""uV

In your components file, put
X-Face: znu_@QbSegynS/\2YND%-w_L.V$bG-M.}<:^^3tS,BszwEdNEo)-/"eZF^+1]M%>A#"QV8U
 #*cFsKsnwC63B`<ee|ik?J'%flkca.~y"QRpTa~0*U~-A2$*bF<OCR3NNl9f8Th79*RvU$D?EsWPU0
 _"Tj_BHv""uV

Finally, remember that if you put this in your MH replcomps file, double-up
the % and \ characters, which are special in that context.  It looks like:

X-Face: znu_@QbSegynS/\\2YND%%-w_L.V$bG-M.}<:^^3tS,BszwEdNEo)-/"eZF^+1]M%%>A#"QV8U
 #*cFsKsnwC63B`<ee|ik?J'%%flkca.~y"QRpTa~0*U~-A2$*bF<OCR3NNl9f8Th79*RvU$D?EsWPU0
 _"Tj_BHv""uV


--8nn+M+O7ej
Content-Type: text/plain
Content-Description: compface.patch
Content-Disposition: inline;
	filename="compface.patch"
Content-Transfer-Encoding: 7bit

*** cmain.c.dist	Thu Oct 24 03:28:07 1991
--- cmain.c	Thu Dec 22 11:55:53 1994
***************
*** 28,33 ****
--- 28,35 ----
  int outfile   = 1;
  char *outname = "<stdout>";
  
+ int xbitmap=0;
+ 
  /* basename of executable */
  char *cmdname;
  
*** file.c.dist	Wed Jun 19 07:29:13 1991
--- file.c	Mon Mar 20 18:11:00 1995
***************
*** 14,19 ****
--- 14,22 ----
   */
  
  #include "compface.h"
+ #ifndef	stderr
+ #include <stdio.h>
+ #endif
  
  void
  BigRead(fbuf)
***************
*** 70,77 ****
--- 73,111 ----
  {
  	register int c, i;
  	register char *s, *t;
+ 	static char table_inv[] = { 0,8,4,12,2,10,6,14,1,9, 5,13, 3,11, 7,15 };
+ 	static char table_nop[] = { 0,1,2, 3,4, 5,6, 7,8,9,10,11,12,13,14,15 };
+ 	char *table = table_nop;	/* optionally invert bits in nibble */
+ 	register inc = 0;		/* optionally swap nimmles */
+ 	int bits;
  
  	t = s = fbuf;
+ 
+ 	/* Does this look like an X bitmap ? */
+ 	if (sscanf(s, "#define %*s %d", &bits) == 1) {
+ 		if (bits == 48) {
+ 			char type1[128];
+ 			char type2[128];
+ 			while (*s && *s++ != '\n');
+ 			if (sscanf(s, "#define %*s %d", &bits) == 1) if (bits == 48) {
+ 				while (*s && *s++ != '\n');
+ 				if (sscanf(s, "static %s %s", type1,type2)==2 &&
+ 					(!strcmp(type1, "char") || 
+ 				    	 !strcmp(type2, "char"))) {
+ 						while (*s && *s++ != '\n');
+ 						inc = 1;
+ 						table = table_inv;
+ 					}
+ 				else fprintf(stderr,
+ 		"warning: xbitmap line 3 not static [unsigned] short ...\n");
+ 			}
+ 			else fprintf(stderr, "warning: xbitmaps must be 48x48\n");
+ 		}
+ 		else fprintf(stderr, "warning: xbitmaps must be 48x48\n");
+ 	}
+ 	/* Ensure s is reset if it was not an X bitmap ... */
+ 	if (! inc) s = fbuf;
+ 
  	for(i = strlen(s); i > 0; i--)
  	{
  		c = (int)*(s++);
***************
*** 82,88 ****
  				status = ERR_EXCESS;
  				break;
  			}
! 			*(t++) = c - '0';
  		}
  		else if ((c >= 'A') && (c <= 'F'))
  		{
--- 116,122 ----
  				status = ERR_EXCESS;
  				break;
  			}
! 			(t++)[inc] = table[c - '0']; inc = - inc;
  		}
  		else if ((c >= 'A') && (c <= 'F'))
  		{
***************
*** 91,97 ****
  				status = ERR_EXCESS;
  				break;
  			}
! 			*(t++) = c - 'A' + 10;
  		}
  		else if ((c >= 'a') && (c <= 'f'))
  		{
--- 125,131 ----
  				status = ERR_EXCESS;
  				break;
  			}
! 			(t++)[inc] = table[c - 'A' + 10]; inc = - inc;
  		}
  		else if ((c >= 'a') && (c <= 'f'))
  		{
***************
*** 100,109 ****
  				status = ERR_EXCESS;
  				break;
  			}
! 			*(t++) = c - 'a' + 10;
  		}
! 		else if (((c == 'x') || (c == 'X')) && (t > fbuf) && (*(t-1) == 0))
! 			t--;
  	}
  	if (t < fbuf + DIGITS)
  		longjmp(comp_env, ERR_INSUFF);
--- 134,143 ----
  				status = ERR_EXCESS;
  				break;
  			}
! 			(t++)[inc] = table[c - 'a' + 10]; inc = - inc;
  		}
! 		else if (((c == 'x') || (c == 'X')) && (t > fbuf) &&
! 			((t-1)[-inc] == table[0])) { t--; inc = -inc; }
  	}
  	if (t < fbuf + DIGITS)
  		longjmp(comp_env, ERR_INSUFF);
***************
*** 127,136 ****
--- 161,179 ----
  {
  	register char *s, *t;
  	register int i, bits, digits, words;
+ 	extern int xbitmap;
+ 	int digsperword = DIGSPERWORD;
+ 	int wordsperline = WORDSPERLINE;
  
  	s = F;
  	t = fbuf;
  	bits = digits = words = i = 0;
+ 	if (xbitmap) {
+ 		sprintf(t,"#define noname_width 48\n#define noname_height 48\nstatic char noname_bits[] = {\n ");
+ 		while (*t) t++;
+ 		digsperword = 2;
+ 		wordsperline = 15;
+ 	}
  	while (s < F + PIXELS)
  	{
  		if ((bits == 0) && (digits == 0))
***************
*** 138,162 ****
  			*(t++) = '0';
  			*(t++) = 'x';
  		}
! 		if (*(s++))
! 			i = i * 2 + 1;
! 		else
! 			i *= 2;
  		if (++bits == BITSPERDIG)
  		{
! 			*(t++) = *(i + HexDigits);
  			bits = i = 0;
! 			if (++digits == DIGSPERWORD)
  			{
  				*(t++) = ',';
  				digits = 0;
! 				if (++words == WORDSPERLINE)
  				{
  					*(t++) = '\n';
  					words = 0;
  				}
  			}
  		}
  	}
  	*(t++) = '\0';
  }
--- 181,223 ----
  			*(t++) = '0';
  			*(t++) = 'x';
  		}
! 		if (xbitmap) {
! 			if (*(s++))
! 				i = (i >> 1) | 0x8;
! 			else
! 				i >>= 1;
! 		}
! 		else {
! 			if (*(s++))
! 				i = i * 2 + 1;
! 			else
! 				i *= 2;
! 		}
  		if (++bits == BITSPERDIG)
  		{
! 			if (xbitmap) {
! 				t++;
! 				t[-(digits & 1) * 2] = *(i + HexDigits);
! 			}
! 			else *(t++) = *(i + HexDigits);
  			bits = i = 0;
! 			if (++digits == digsperword)
  			{
+ 				if (xbitmap && (s >= F + PIXELS)) break;
  				*(t++) = ',';
  				digits = 0;
! 				if (++words == wordsperline)
  				{
  					*(t++) = '\n';
+ 					if (xbitmap) *(t++) = ' ';
  					words = 0;
  				}
  			}
  		}
+ 	}
+ 	if (xbitmap) {
+ 		sprintf(t, "}\n");
+ 		while (*t) t++;
  	}
  	*(t++) = '\0';
  }
*** uncmain.c.dist	Thu Oct 24 03:28:07 1991
--- uncmain.c	Thu Dec 22 09:58:34 1994
***************
*** 28,33 ****
--- 28,35 ----
  int outfile   = 1;
  char *outname = "<stdout>";
  
+ int xbitmap=0;
+ 
  /* basename of executable */
  char *cmdname;
  
***************
*** 59,64 ****
--- 61,73 ----
    while (**argv)
      if (*((*argv)++) == '/')
        cmdname = *argv;               /* find the command's basename */
+ 
+   if (argc > 1 && !strcmp(argv[1], "-X"))
+     {
+       xbitmap++;
+       argc--;
+       argv++;
+     }
  
    if (argc > 3)
      {

--8nn+M+O7ej
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit


-- 
Karl M. Hegbloom <karlheg@inetarena.com>
http://www.inetarena.com/~karlheg
Portland, OR  USA
Debian GNU 1.2  Linux 2.0.30t
You tell me and we'll both know.


--8nn+M+O7ej--

