cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/11/01:57:21

Message-Id: <199908091924.PAA21518@delorie.com>
From: "Batchex" <thedark1 AT kubrick DOT hotpop DOT com>
Organization: Digital Arts Creatives
To: djgpp AT delorie DOT com
Date: Tue, 10 Aug 1999 02:27:14 +0000
MIME-Version: 1.0
Subject: Re: decoding pcx header
In-reply-to: <19990809021704.05022.00001581@ng-ce1.aol.com>
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> 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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019