[comp.graphics] Sun im8 Format

reher@ucunx1.san.uc.edu (Jay R. Reher) (04/17/91)

	Can anyone give me any information on on the Sun im8 file format.
I seem to get the image data ok, but the color table is really screwed. Any
 help appreciated.. Thanx in advance !
	
						Jay Reher
	

srnelson@nelsun.Eng.Sun.COM (Scott R. Nelson) (04/19/91)

From article <1991Apr17.042020.15738@ucunx1.san.uc.edu>, by reher@ucunx1.san.uc.edu (Jay R. Reher):
> 
> 	Can anyone give me any information on on the Sun im8 file format.
> I seem to get the image data ok, but the color table is really screwed. Any
>  help appreciated.. Thanx in advance !

Since no one else seems to have followed up on this, here's the
information that covers color tables for all Sun rasterfile formats:

The rasterfile header looks like:

struct rasterfile {
        int     ras_magic;              /* magic number */
        int     ras_width;              /* width (pixels) of image */
        int     ras_height;             /* height (pixels) of image */
        int     ras_depth;              /* depth (1, 8, or 24 bits) of pixel */
        int     ras_length;             /* length (bytes) of image */
        int     ras_type;               /* type of file */
        int     ras_maptype;            /* type of colormap */
        int     ras_maplength;          /* length (bytes) of following map */
        /* color map follows for ras_maplength bytes, followed by image */
};

More information may be found in /usr/include/rasterfile.h.

Typically the maplength will be 768 which means there are three sets
of color ramps, each 256 bytes long.  The first 256 bytes are the red
color map, the next green and the last 256 bytes are the blue ramp.
If maplength is less than 768, divide by 3 to get the length of each
of the red, green and blue ramps.

You can read the color ramps directly into a character array and then use
the 8-bit index to get the color values from each of the three arrays.

---

Scott R. Nelson			srnelson@eng.sun.com
Sun Microsystems

"Proofread carefully to see if you any words out."