www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/09/13/20:08:02

Date: 13 Sep 94 14:20 -0700
From: Philip Hodder <hodder AT geop DOT ubc DOT ca>
To: <djgpp AT sun DOT soe DOT clarkson DOT edu>
Subject: Palette problem with GRX 1.03m1 (& djgpp 112m1)

Hi,
	I've been playing around with writing an image display program - this
is for astronomical images so everything is greyscale (and 8 bit data also).
I seem to have run into a problem when trying to display 64 grey levels using
GRX 1.03m1 (you can only display 64 (6 bit) distinct grey levels on VGA).

I set up a palette of 256 colours:

  for (i=0; i<256; i++) { 
    j = i / 4; 
    pal[i] = GrAllocColor(j, j, j); 
  }

i.e. pal[0], pal[1], pal[2], pal[3] are black (0), [4], [5], [6] & [7] have
intensity 1, etc. However this doesnt seem to work! What I get is 16 levels,
specifically (using GrQueryColor to recover the intensities):

COLOR INDEX      R/G/B
pal[0] = 0       0/0/0
...
pal[7] = 0       0/0/0
pal[8] = 14      4/4/4
...
pal[23] = 14     4/4/4
pal[24] = 13     8/8/8
... continues in blocks of 16 until ...
pal[248] = 16    64/64/64
...
pal[255] = 17    64/64/64

GrBlack() returns 0; GrWhite() returns 15 - so there are a total of 16 colours
instead of 64!

I'm fairly sure that the arrays etc are being allocated properly - the program
does work, just not the way I want it to! I've read the documentation, and have
used GrAllocColor in other programs with no problem - I think I'm missing
something obvious and was hoping someone could point it out.

I hope this makes sense to you all - I can try a more detailed explanation if
needed.

	Thanks in advance,

			Phil.

------------------------------------------------------------------------------
  Philip J. C. Hodder                      INTERNET: hodder AT geop DOT ubc DOT ca
  Dept. of Geophysics & Astronomy          PHONE:    (604) 822-6722 
  #129-2219 Main Mall                      FAX:      (604) 822-6047
  University of British Columbia          
  Vancouver, British Columbia, Canada         
  V6T 1Z4                                  
------------------------------------------------------------------------------
"The further thought occurs that we haven't budged a smegging inch!"
						           - Rimmer, Red Dwarf
------------------------------------------------------------------------------


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019