home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / graphics / 14188 < prev    next >
Encoding:
Internet Message Format  |  1993-01-25  |  1.7 KB

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