Index: [thread] [date] [subject] [author]
  From: Christoph Egger <Christoph_Egger@t-online.de>
  To  : ggi-develop@eskimo.com
  Date: Sun, 4 Jul 1999 08:21:42 +0200 (MEST)

Re: Got to be a faster way.

On Sat, 3 Jul 1999, Andreas Beck wrote:

> > > If that doesn't work, as you are using a palettized visual, you will very
> > > probably want to set up the palette in a way that allows to calculate the
> > > palette entry from the pixelvalues. Everything else is slow.
> 
> > How is the pallete set with ggiSetColorfulPallete?  Is it a full 3-2-3 bit
> > distribution?  Or something else?
> 
> This is undefined. To allow for window-systems e.g. which have a common
> palette to apps. On these a ColorfulPallete will include already set values
> and try to optimize to get most colors with least additional ones.
> 
> You have to set up the palette yourself to be in control.
> 
> > With the pallete with set with 3 red, 2 green, and 3 blue (or some similar
> > configuration (I might weight green heavier as the human eye is more
> > sensitive to green)) and then set the pallete in order like:
> > 
> > 000-00-000
> > 000-00-001
> > ...
> > 111-11-110
> > 111-11-111
> 
> Yes. I'd probably give the 2 to blue.
> 

I agree with you.


How about with this:

/* generate_332_palette:
 *  Used when loading a truecolor image into an 8 bit bitmap, to generate
 *  a 3.3.2 RGB palette.
 */
void generate_332_palette(ggi_color *pal)
{
   #define PAL_SIZE 256
   ggi_sint c;

   for (c=0; c < PAL_SIZE; c++) {
      pal[c].r = ((c>>5)&7) * 0xffff/7;
      pal[c].g = ((c>>2)&7) * 0xffff/7;
      pal[c].b = (c&3) * 0xffff/3;
   }

   pal[0].r = 0xffff;
   pal[0].g = 0;
   pal[0].b = 0xffff;

   pal[254].r = pal[254].g = pal[254].b = 0;
   #undef PAL_SIZE
} // generate_332_palette


Any comments?
Is that worth to integrate it into libggi or libggi2d?


Christoph Egger
E-Mail: Christoph_Egger@t-online.de

Index: [thread] [date] [subject] [author]