05-13-2003, 05:31 PM
Quote:file is generating 8-bit RGB data, not 6-bit data. Windows PCX viewers will generally display that just fine. DOS programs generally won't. (And QB's PALETTE statement really doesn't like 8-bit RGB data.)
True. Look at this specs of the PCX format (from ZSoft, circa 1987):
Code:
VGA 256 Color Palette Information
ZSoft has recently added the capability to store palettes containing more
than 16 colors in the .PCX image file. The 256 color palette is formatted
and treated the same as the 16 color palette, except that it is substantially
longer. The palette (number of colors x 3 bytes in length) is appended to
the end of the .PCX file, and is preceded by a 12 decimal. Since the VGA
device expects a palette value to be 0-63 instead of 0-255, you need to
divide the values read in the palette by 4.
So by default PCXs use 8 bits for each colour component. You just divide the values by four in your program when you are loading it and changing the DAC registers.
As the palette is appended at the end of your PCX file, a good way of reading the palette could be:
Code:
f% = FREEFILE
o$ = CHR$(0) ' Trick to read just one byte :)
OPEN "myfile.pcx" FOR BINARY AS #f%
SEEK #f%, LOF(f%) - 767
FOR i% = 0 TO 255
OUT &H3C8, i%
FOR j% = 1 TO 3
GET #f%, , o$
OUT &H3C9, ASC(o$) \ 4
NEXT j%
NEXT i%
CLOSE #f%
[Note that this may need a fix: I wrote it from the top of my head]
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i