sc...@whiplash.res.cmu.edu (Scott F. Earnest) wrote:
Quote
>In article <4mepi6$...@scipio.{*word*104}store.ca> tetsuosmail...@dsoe.com (xxx xxx) writes:
>>More specifcally...how do you read the pallette from a Deluxe Paint
>>Enhanced PCX file? I have tired and all the color come though screwed up
>>and I can't figure out why? Has anyone else come across this problem.
>There are several PCX variations, and I'll have to assume you're working
>with the 256-color variety (this may or may not be the same as your
>"enhanced" PCX, though). 256-color PCX files normally have a 768-byte color
>palette at the end of the file. You can read it in with something like:
<snip>
perhaps the problem could be that maybe E-PCX uses a palette based on
256 shades of any given color, while the VGA only uses 64 shades...
you can use a 256-shade based setpalette by doing this:
procedure SetPalette256 (var pal); assembler;
asm
mov bx, ds
lds di, pal
mov dx, 03C8h
xor ax, ax
out dx, al
mov cx, 384
@Loop:
mov ax, [di]
shr ax, 2
out dx, al
shr ax, 8
out dx, al
add di, 2
dec cx
jnz @Loop
mov ds, bx
end;
heh, sorry about the highly-optimized setpalette there... i've got
this {*word*193} habit of optimizing as i go :) anyway, i'd imagine that
your normal setpalette is simply something as incredibly droll as:
for i := 0 to 255 do
setrgb (i, pal[i,0], pal[i,1], pal[i, 2]);
just change that to:
for i := 0 to 255 do
setrgb (i, pal[i,0] div 4, pal[i,1] div 4, pal[i, 2] div 4);
if you want to convert my piece of artwork above to a regular 64-level
palette, just kill the 'shr ax, 2' and save 384 clock-cycles :)
hmmm, another thought occurs to me about your colors... i think that
the PCX format stores the colors in the order bgr instead of rgb...
and it may even bitwise-pack everything together too... (this is why i
don't use PCX :)
---
quantum porcupine, coder, musician | that which is, is not
and porcupine. mailto:jsha...@nmsu.edu | that which can, can not
http://infinity.beve.blacksburg.va.us/~porcpine | that which does, does not