delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/07/12/07:14:36

Date: Tue, 12 Jul 1994 12:13:28 +0100 (CET)
From: "Roland Exler" <R DOT Exler AT jk DOT uni-linz DOT ac DOT at>
Sender: k3a0270 AT pop DOT uni-linz DOT ac DOT at
Reply-To: R DOT Exler AT jk DOT uni-linz DOT ac DOT at
To: <djgpp AT sun DOT soe DOT clarkson DOT edu>
Subject: bug in libgrx

I've to alloc all 256 colors availiable by my application, but because
GrBlack and GrWhite are pre-defined there are only 254 colors free.

So I used GrFreeColor(GrBlack()) and GrFreeColor(GrWhite()) to get all 256
colors free. This works fine if I then get my colors with GrAllocColor, but
if I used GrAllocCell to get all 256 colors, I've still got only 254!
Looking at the source of function GrFreeColor in libgrx\src\colors.c I
found that the color-state is set to availiable, but the number of free
colors isn't updated. GrAllocColor doesn't check freecolors, but GrAllocCell
does!

So if you change function GrFreeColor by the included new one and rebuild
the library, anything will work ok.
(I hope i've not built in new side-effects)

Roland
+---------------------------------------+---------------------------+
I Roland Exler                          I EMAIL:                    I
I Universitaet Linz                     I R DOT Exler AT jk DOT uni-linz DOT ac DOT at I
I Institut fuer Elektrische Messtechnik I                           I
I Altenbergerstr. 69                    I Phone:                    I
I A-4040 Linz, AUSTRIA                  I + 43 732 2468 9205        I
+---------------------------------------+---------------------------+
void GrFreeColor(int n)
{
	color *c;

	if(init_done() && !RGBmode &&
	   ((unsigned)n < (unsigned)_GrNumColors) &&
	   ((c = &colortable[n])->state != C_FREE)) {
	    if(c->n > 0)  c->n--;
/* original
	    if(c->n == 0) c->state = C_FREE;
  Exler! */
	    if(c->n == 0) {c->state = C_FREE; freecolors++;}
	}
}

- Raw text -


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