Mail Archives: djgpp/1994/09/14/06:20:05
Philip Hodder <hodder AT geop DOT ubc DOT ca> writes:
> 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);
> }
You say you have only 64 cells in your color table, and you are allocating 256
cells (calling GrAllocColor() 256 times).
Once the color table is full, you will get wrong results. There are
functions to query the number of free cells, see grx/src/colors.c
It is probably a good idea to allocate all available/needed cells first
and then set the colors.
int cell;
for (i=0; i<64; i++) {
if ((cell = GrAllocCell()) != GrNOCOLOR)
GrSetColor(cell, level, level, level);
else
/* Color table used up */
....
}
> GrBlack() returns 0; GrWhite() returns 15 - so there are a total of 16
colours
> instead of 64!
The 16 first cells were probably allocated earlier (before your call).
Hope this helps,
Piet
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
P. Mertens tel: +32.16..28.47.63
Department of Linguistics fax: +32.16..28.50.25
Centre for Computational Linguistics email: pmertens AT cc3 DOT kuleuven DOT ac DOT be
K.U.Leuven Piet DOT Mertens AT arts DOT kuleuven DOT ac DOT be
Blijde-Inkomststraat 21
3000 Leuven (Belgium)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Raw text -