[comp.graphics] Questions about the Sun raster image file format

jdm@hodge.UUCP (jdm) (08/24/89)

	I'm doing some conversion work involving Sun raster image files
	and I've not been about to find good answers to the following
	questions:

	1) If the ras_maptype is RMT_RAW how are the RGB values stored
	   in the colormap?  Are they RGBRGBRGBRGBRGBRGB (by pixel) as
	   opposed to RRRRRRRGGGGGGGGGBBBBBBB (by plane) when ras_maptype
	   is RMT_EQUAL_RGB?

	2) If ras_maptype is RMT_NONE is there any colormap data in the
	   file?  The man page for rasterfile says they colormap is
	   "empty" when ras_maptype is RMT_NONE.  Does this mean all the
	   values in the colormap are 0 or the colormap data just isn't 
	   in the file?

	3) How is the actual image data formatted when there is and isn't
	   a colormap?  With a colormap is each pixel just a byte that
	   contains an index into the colormap?  Without a colormap is
	   the RGB data stored a pixel at a time or a plane at a time?
	   (i.e. RGBRGBRGBRGBRGBRGBRGB versus RRRRRRRGGGGGGGBBBBBBB).


-- 

"I'm an anthropologist, not a computer systems architect, damit!"

jdm@hodge.cts.com [uunet zardoz crash]!hodge!jdm

James D. Murray, Ethnounixologist	TEL: (714) 998-7750 Ext. 129	
Hodge Computer Research Corporation	FAX: (714) 921-8038
1588 North Batavia Street 
Orange, California 92667  USA

mic@ut-emx.UUCP (Mic Kaczmarczik) (08/25/89)

In article <21639@hodge.UUCP> jdm@hodge.UUCP (jdm) writes:
>
>	I'm doing some conversion work involving Sun raster image files
>	and I've not been about to find good answers to the following
>	questions:
>
>	1) If the ras_maptype is RMT_RAW how are the RGB values stored
>	   in the colormap?  Are they RGBRGBRGBRGBRGBRGB (by pixel) as
>	   opposed to RRRRRRRGGGGGGGGGBBBBBBB (by plane) when ras_maptype
>	   is RMT_EQUAL_RGB?

	By pixel.  Each color map entry is a 24-bit color value in the memory
	format used by the Sun frame buffer: 1 byte each of blue, green, and
	red.  The blue byte comes first in memory, not the red byte.  When you
	look at the color value as a 32-bit 68000 format integer, the red byte
	is in the least significant position.  I learned this the hard way. :-)

>	2) If ras_maptype is RMT_NONE is there any colormap data in the
>	   file?  The man page for rasterfile says they colormap is
>	   "empty" when ras_maptype is RMT_NONE.  Does this mean all the
>	   values in the colormap are 0 or the colormap data just isn't 
>	   in the file?

	If ras_maptype is RMT_NONE, then ras_maplength should probably be 0,
	indicating that there is definitely no color map data in the
	rasterfile.  If it isn't 0, then my approach would be to skip over any
	colormap data provided.  If ras_maptype is RMT_NONE, there's no
	knowing what format the colormap data is in, anyway. 

>	3) How is the actual image data formatted when there is and isn't
>	   a colormap?

	There is no difference in the memory format of 8-plane image data
	between image files with a color map, and those without. The frame
	buffer's color map is always implicitly there, even if not specified
	in the rasterfile.   24-plane image data is of course different
	because it uses direct color values instead of a color map.

>			  With a colormap is each pixel just a byte that
>	   contains an index into the colormap?

	Yes.  Without a color map, you just guess what the pixels mean.  Most
	programs I've seen assume that the bytes represent gray scale values
	in this case.  This is the same as assuming a color map that ramps
	from (0,0,0) to (255,255,255).

>	   the RGB data stored a pixel at a time or a plane at a time?
>	   (i.e. RGBRGBRGBRGBRGBRGBRGB versus RRRRRRRGGGGGGGBBBBBBB).

	A pixel at a time, regardless of the depth or color map.  24-plane
	images use raw color values for the pixels, in the same triplet format
	as RMT_RAW map entries, and don't have color maps.  8-plane images
	have only a single byte of data per pixel.  So, for 24-plane files the
	order is
		BGRBGRBGRBGR

	One complication is that each scan line in the image is padded to
	16-bit shortword boundaries, so if there are an odd number of bytes in
	the data for the scan line, you need to add an extra dummy byte to
	make the number even. 

The Sun rasterfile format uses the memory format of the data
structures used by the Sun pixrect library.  I learned a lot of this
information from the pixrect programming guide, and also got
information about color maps from the SunView programmer's guide.

>jdm@hodge.cts.com [uunet zardoz crash]!hodge!jdm
>
>James D. Murray, Ethnounixologist	TEL: (714) 998-7750 Ext. 129	
>Hodge Computer Research Corporation	FAX: (714) 921-8038
>1588 North Batavia Street 
>Orange, California 92667  USA


-- 
Mic Kaczmarczik					   Internet: mic@emx.utexas.edu
Unix/VMS Services 				   BITNET: MIC@UTAIVC
UT Austin Computation Center			   THEnet: UTAIVC::MIC

     Don't worry about life, son. It ain't nohow permanent.  -- Walt Kelly