Hello,

16 bit bitmaps do not use palette, but the color values. The code bellow
converts 24 bit RGB (i.e. the array r,g,b,r,g,b,r,g,b,r,g,b,...)
to 16 bit. It is an inplace conversion, therefore the complications at the
beginning.

With best regards,
    Jan Slodicka

static void Convert24To16( unsigned char* buffer, long size )
{
 unsigned char dst ;
 unsigned char *out = buffer;
 size /= 3;

 // Process the first pixel, write to a temp buffer so we don't overwrite
the source
 // Converting directly to 565BE, |G/2|B|R|G/2| when swapped =>
|B|G/2+G/2|R|

 dst = ((buffer[1] << 3) & 0xE0) | (buffer[0] >> 3);
 *out++ = (buffer[2] & 0xF8) | ((buffer[1] >> 5) & 0x7);
 *out++ = dst;

 buffer+=3;
 size--;

 while( size )
 {
  // convert 24 bit RGB to 16bit (5-6-5) RGB
  *out++ = (buffer[2] & 0xF8) | (buffer[1] >> 5);
  *out++ = ((buffer[1] << 3) & 0xE0) | (buffer[0] >> 3);
  buffer+=3;
  size--;
 }
}


----- Original Message ----- 
From: "Marilia Mendes" <[EMAIL PROTECTED]>
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent: Wednesday, September 22, 2004 8:14 PM
Subject: images with depth 16


> please, somebody could give an example
> or something that can help me on as to place 16 bits
> in one bitmap?
> because I only know to place 256 colors, using pallete
> of colors, but with depht=16 does not use WinPallete.
> How I make?
>
> Thanks
>
>
>
>
>
>
> _______________________________________________________
> Yahoo! Messenger 6.0 - jogos, emoticons sonoros e muita divers�o. Instale
agora!
> http://br.download.yahoo.com/messenger/
>
> -- 
> For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to