Mail Archives: djgpp/1999/08/11/01:57:21
> From: guybrush03 AT aol DOT com (Guybrush03)
> Subject: Re: decoding pcx header
> Date: 09 Aug 1999 06:17:04 GMT
> Organization: AOL http://www.aol.com
> To: djgpp AT delorie DOT com
> Reply-to: djgpp AT delorie DOT com
> Andre LaMothe goes through this in "Black Art of 3D Game Programming". The
> process is something like this:
> read in first 128 bytes if you want the header info (header is constant as
> first 128 bytes). then goto the end of the file and backup 768 bytes (256 * 3
> color spots for RGB). from here you can read the file's palette info. then,
> using the data in between the two spots you've read, just use a RLE decoding
> method to extract the actual image data (i'm assuming you know of RLE
> decoding...just drop a line here if you don't). HTH
>
This is true for 256 color PCX format. For 4 bit and 24 bit PCX
format, things get a little hairy. For safety reasons, I guess you'll
want to know these information from the PCX header :
offset 3 1 byte bits per pixel
offset 4 8 bytes image dimensions (4 integer, 2 bytes each)
offest 65 1 byte number of planes
offset 66 2 bytes bytes per scanline
For 8 bit (256) color, the palette is 768 bytes from the end of the
file in RGB format. For 4 bit color, the palette is at offset 48 in
RGB format. For 24 bit color, there is no palette info, cause the RGB
value itself is written in the image data.
Image dimensions is stored in top left X & Y then bottom left X & Y.
Each coordinate is 2 byte integer.
Number of planes indicate how many planes is used. 4 for 4 bit color
and 3 for 24 bit color.
Unlike the 8 bit color format, the 4 bit & 24 bit format needs extra
work for decoding the RLE. Here, each scanline from each planes is
stored and then compressed. So to decompress such data, first
decompress all the image data to a buffer. Then, take as many bytes
as the bytes per scnaline entry states from the buffer to each plane
buffer. The first byte per scanline bytes belong to plane 0, then
plane 1, plane 2, plane 3, then plane 0 again and so on until the end
of the buffer.
Hope that helps.
Batchex
thedark1 AT Phreaker DOT net
- Raw text -