[comp.windows.x] Pixmap color compression

raveling@vaxa.isi.edu (Paul Raveling) (03/15/88)

In article <927@xn.LL.MIT.EDU> wjc@XN.LL.MIT.EDU (William J. Chiarchiaro) writes:
>Does anyone know of an algorithm for doing the following:
>
>	Take a digitized, color image composed of 24-bit pixels
>     (8 bits red, 8 bits green, 8 bits blue), and convert it to
>     an 8-bit-per-pixel color image along with a suitable
>     256-entry colormap (each entry has 8 bits of red, 8 of green,
>     and 8 of blue).


	I've posted our utilities to do this sort of thing on
	vaxa.isi.edu, available via anonymous ftp from pub/X.
	Also posted are three sample pixmaps generated from
	the same data, using 16, 32, and 200 colors.

	The color allocation routine, alcols.c, attempts to produce
	color assignments fairly close to optimal while running
	reasonably fast.  A 512x480 pixmap requires about 1 1/2
	minutes to process on an HP 9000/350, and the sample pixmaps
	show good image quality even at 16 colors.

	I can supply the source of alcols.c by email to anyone
	without ftp access (If it's possible to reach you by email!).
	This module depends on virtually nothing and should be
	easily portable.

	Other files in the util subdirectory are various related utilities.
	Most use X10.4.  Those most appropriate to the color compression
	problem are:

		genpix.c	Program using alcols.c to generate
				a pixmap file from separate files of
				red, green, and blue pixel data
		
		viewpix.c	Pixmap viewer --  displays pixmap files
				created by genpix, plus a magnified
				image of pixels around the cursor.
				Viewpix accepts pixmap files in either
				compressed or uncompressed format.
	
	Easiest way to everything is by getting:

		pub/X/util.tar.Z
				All util sources, 94,269 bytes.
				Generates "./util/*" when unpacked.
				See ./util/README and ./util/*.doc
				for more info.
		
		pub/X/sample_pixmaps.tar

				Three pixmaps showing map of South China
				Sea area, 348,160 bytes.  This is a TAR
				file of compressed pixmap files, will
				generate "./sample_pixmaps/*" when unpacked.



---------------------
Paul Raveling
Raveling@vaxa.isi.edu