[comp.windows.x] Convert TO xbm

phil@ux1.cso.uiuc.edu (10/11/90)

Does anyone have tools that convert OTHER graphics formats TO the .xbm format?

--Phil Howard, KA9WGN-- | Individual CHOICE is fundamental to a free society
<phil@ux1.cso.uiuc.edu> | no matter what the particular issue is all about.

iant@hpopd.HP.COM (Ian Thornton) (10/12/90)

> Does anyone have tools that convert OTHER graphics formats TO the .xbm format?

	If you have 'gjet' then I can help. I've written a short (and very 
	crude) C prog which converts raw PCL bit data (from stdin) into
	a bitmap file (on stdout).

	The compiled binary takes one parameter in the form of
	WIDTHxHEIGHT e.g. 

	toxbm 640x480

	The reason for this odd method of specifying the width and height
	is that this is the format which gjet produces on stderr
	when converting another format into raw PCL data.

	The following example converts the gif file 'pic.gif' into the bitmap
	'pic.xbm'

	cat pic.gif|gjet -fg -i -mh -or 2>tmp.dim >tmp.raw
	read dimension <tmp.dim
	toxbm $dimension <tmp.raw >pic.xbm
	rm tmp.dim tmp.raw

	'gjet' can convert from many more formats other than GIF. Used in
	conjunction with 'xloadimage', there is not a single format I have
	been unable to convert.

	Hope I've been helpful
					Ian Thornton.


			(PS. Having said all this, I'm sure there must be a
			     simpler way of doing this !)

-------------------------------- Cut here--------------------------------------

/* 	'toxbm.c'

	Takes raw laserjet bit data as input and produces an X11 bitmap file
	called 'name' on stdout.

	Takes 1 paramter which is the size of the image. Its form is
	WIDTHxHEIGHT e.g. 1024x768.
*/

#include <stdio.h>
#include <stdlib.h>

main(argc, argv)
int argc;
char *argv[];
{
	int width, height, i, b, c, n, col = 0;
	char *wptr, *hptr;

	if (argc != 2) {
		fprintf(stderr, "Usage: %s WIDTHxHEIGHT\n", argv[0]);
		exit(1);
	}

/*	Locate the first and second parameters				*/	

	wptr = argv[1];
	hptr = wptr;
	while ( *hptr != 'x')
		hptr++;
	*hptr = '\0';
	hptr++;

/*	Convert the two trings to integers				*/

	width = (int) atol(wptr);
	height = (int) atol(hptr);

	fprintf(stderr, "%dx%d\n", width, height);


/*	Write the bitmap header						*/

	printf("#define name_width	%d\n",width);
	printf("#define name_height	%d\n",height);
	printf("static char name_bits[] = {\n");

	for (i = 1; i <= width*height/8; i++){

		c = getc(stdin);
		b = 0;

/*	Reverse the order of the bits					*/

		for (n = 0; n < 8; n++){
			b = b << 1;
			if (c & 0x01)
				b = b | 0x01;
			c = c >> 1;
		}
/*	Output the byte in the correct format 				*/

		printf("0x%02x", b);
		if (i != width*height/8)
			printf(", ");
		if ((++col % 12) == 0)
			printf("\n");
	}

 	printf(" };\n");
}

phil@ux1.cso.uiuc.edu (10/15/90)

Just to summarize the responses I have gotten; almost ALL mail about how to
convert TO the xbm format has suggested using the "pbmplus" package.  This
package is available for FTP from:

ads.com:pub/VISION-LIST-ARCHIVE/SHAREWARE/pbmplus.tar.Z
cindy.csuchico.edu:pub/src/pbmplus.tar.Z
decuac.dec.com:public/sources/X11/pbmplus.tar.Z
e.ms.uky.edu:pub/graphics/pbmplus.tar.Z
expo.lcs.mit.edu:contrib/pbmplus.tar.Z
f.ms.uky.edu:pub/graphics/pbmplus.tar.Z
ftp.uu.net:X/contrib/pbmplus.tar.Z
gatekeeper.dec.com:pub/X11/R3-contrib/pbmplus.tar.Z
gatekeeper.dec.com:pub/X11/contrib/pbmplus.tar.Z
giza.cis.ohio-state.edu:pub/X-contrib/pbmplus.tar.Z
hp4nl.nluug.nl:pub/windows/X/contrib/pbmplus.tar.Z
hpserv1.uit.no:pub/graphics/src/pbmplus.tar.Z
hq.af.mil:pub/pbmplus.tar.Z
icarus.riacs.edu:pub/pbmplus.tar.Z
irisa.irisa.fr:pub/graphics/pbmplus.tar.Z
lth.se:Rastertools/Pbmplus/pbmplus.tar.Z
nac.no:pub/pbmplus.tar.Z
miranda.riacs.edu:pub/pbmplus.tar.Z
munnari.oz.au:pub/pbmplus.tar.Z
pollux.lu.se:pub/graphics/tools-unix/pbmplus.tar.Z
sachiko.acc.stolaf.edu:OpticalDisk/src/local/bin/.tar/pbmplus.tar.Z
sachiko.acc.stolaf.edu:home/sachiko/cdr/tmp/Tar/pbmplus.tar.Z
tut.cis.ohio-state.edu:pub/pbmplus/pbmplus.tar.Z
ucsd.edu:graphics/pbmplus.tar.Z
unido.informatik.uni-dortmund.de:pub/windows/X/contrib.R4/pbmplus.tar.Z
urd.lth.se:Rastertools/Pbmplus/pbmplus.tar.Z
utsun.s.u-tokyo.ac.jp:X/pbmplus.tar.Z
uunet.uu.net:X/contrib/pbmplus.tar.Z
van-bc.wimsey.bc.ca:pub/graphics/pbmplus.tar.Z
xanth.cs.odu.edu:incoming/pbmplus.tar.Z

This list is not complete, but then considering how big it is now, who cares.
The duplicates on gatekeeper and sachiko appear to be identical.

--Phil Howard, KA9WGN-- | Individual CHOICE is fundamental to a free society
<phil@ux1.cso.uiuc.edu> | no matter what the particular issue is all about.