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

Re: Got to be a faster way.

On Sun, 4 Jul 1999, Club Neon wrote:

> > 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?
> 
> How about a question?  Why is pal[0] magenta, and pal[254] black?  Am I
> missing something?
> 
> I was thinking that pal[0] would be black, and I guess pal[254] would be
> almost white, slightly yellow tinted.
> 

Oh - if I am understanding you correctly, you mean ...

/* 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 = 0;
   pal[0].g = 0;
   pal[0].b = 0;

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

... instead the first above, no?

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

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