Index:
[thread]
[date]
[subject]
[author]
From: Steve Cheng <elmert@ipoline.com>
To : Christoph Egger <Christoph_Egger@t-online.de>
Date: Sun, 4 Jul 1999 14:19:06 -0400 (EDT)
Re: Got to be a faster way.
On Sun, 4 Jul 1999, Christoph Egger wrote:
>
>
> 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
>
>
--
Steve Cheng
email: steve@ggi-project.org
www: <http://shell.ipoline.com/~elmert/>
Index:
[thread]
[date]
[subject]
[author]