Board index » delphi » Reading Deluxe Paint E PCX

Reading Deluxe Paint E PCX

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.

--
------------------------------------------------------------------------
You can talk to me in real time at my Favorite Chat system in the world:
Illusive Deceptions. If you feel like callin the distance to some very
friendly people and some smooth and colorful software, Dial
1-604-522-2115...522-7440 and 522-7417. If you call a G-TALK or STS system
then convice your system operator to LINK with us for a couple of hours.
We would love to chat with you. We will be Telinking soon so you won't
need to spend the money on LD or callin the numbers.

 A message from

            TETSUO(currently known as Tuxedo Mask)

"Leaving? So soon?  HOW RUDE." - Megabyte

------------------------------------------------------------------------

 

Re:Reading Deluxe Paint E PCX


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:

type
  TPalette = array[0..255,0..2] of byte;

var
  PCX : file;
  pal : TPalette;

begin
  assign (PCX,'myimage.pcx');
  reset (PCX,1);
  seek (PCX,filesize(PCX)-768);
  blockread (PCX,pal,sizeof(pal));
  close (PCX);
  {feed 'pal' to your procedure that sets the VGA palette}
end;

Quote
>--
>[sig snipped]

--
Scott F. Earnest           | We now return you to our regularly scheduled
sc...@whiplash.res.cmu.edu | chaos and mayhem. . . .

Re:Reading Deluxe Paint E PCX


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

Re:Reading Deluxe Paint E PCX


Quote
Scott F. Earnest wrote:

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

And I think the byte immediately preceding the palette should be a 12 to
indicate that a palette really is stored there ...

... but I wouldn't bet on that ;-)

   __/  __/   -  Christian Froeschlin
  /    /
 /     _/     * If you eliminate the impossible, whatever remains, *
___/ _/       * however improbable, must be the BUG !              *

Other Threads