home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!haven.umd.edu!mimsy!ringding.cs.umd.edu!marko
- From: marko@ringding.cs.umd.edu (Marko Teittinen)
- Newsgroups: comp.graphics
- Subject: Re: BGI and PCX
- Message-ID: <63694@mimsy.umd.edu>
- Date: 25 Jan 93 20:57:41 GMT
- References: <davisrj.727563884@signal.ece.clarkson.edu>
- Sender: news@mimsy.umd.edu
- Lines: 34
- X-Newsreader: TIN [version 1.1 PL6]
-
- Roy J. Davis (davisrj@signal.ece.clarkson.edu) wrote:
- > I've been doing a little graphics programming with the Borland BGI
- > interface using 16 color, 4 plane PCX files. I've had no problems
- > decoding the image but have not been able to get the palette
- > correct. I've been trying to use setrgbpalette() with the palette
- > values from the PCX file. What am I doing wrong?
- >
- > Will I also have this problem when I try doing the same thing with
- > the 256 color files?
- >
- > Anyone out there have some simple C code that might show me what my
- > porblem is?
-
- Your problem is that VGA uses double mapping in its 16 color mode.
- When you use setcolor(), you select the color index in the 16-color
- palette, but these 16-colors have a mapping to the first 64 colors
- in the full 256 color palette. And setrgbpalette uses these 256 color
- palette indexes. This is a bit complicated, buy a book and read the
- details there.
-
- But the simplest solution to your palette problem is the following.
-
- for (i = 0; i < 16; i++)
- setpalette(i,i); /* match 16-color index with 256 color code */
-
- After that piece of code, the setrgbpalette() calls work as expected.
-
- This double indexing is done to maintain some EGA-compatibility.
-
- Marko
- --
- Marko Teittinen, PhD student, Computer Science
- University of Maryland, College Park
- marko@cs.umd.edu
-