[maemo-developers] [maemo-developers] Nokia SDL color format for pixels
From: Joni Valtanen jvaltane at kapsi.fiDate: Thu Aug 28 16:19:06 EEST 2008
- Previous message: [maemo-developers] Nokia SDL color format for pixels
- Next message: [maemo-developers] Nokia SDL color format for pixels
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, 28 Aug 2008, Michael Stepanov wrote: > On Tue, Apr 15, 2008 at 3:50 PM, Frantisek Dufka <dufkaf at seznam.cz> wrote: > >> Michael Stepanov wrote: >> >>> So, how in that situation I can get correct color? >>> >> >> It is already correct. The color format is RGB565. What 'correct' means to >> you in this context? If you need the value in different format you need to >> convert it. >> >> > Yes, I need to convert RGB565 to RGB888 to compare two values - actual pixel > color and pink color. Could you suggest me, please, some way to do that? If you converts 565 to 888 you should do some and(&) to 888 also because three less meaning bits are missing from red and blue, and two bits from green. so I recommend to do 888->565 conversion. Following example should work. /* convert RGB888 to RGB565 */ ....... #define R_RGB888_OFFSET 16 #define G_RGB888_OFFSET 8 #define R_RGB565_OFFSET 11 #define G_RGB565_OFFSET 5 ....... /* get rgb888:s r,g and b */ uint8 r8 = (rgb888 & 0xff0000) >> R_RGB888_OFFSET; uint8 g8 = (rgb888 & 0xff00) >> G_RGB888_OFFSET; uint8 b8 = rgb888 & 0xff; /* creates rgb565 from r8, g8 and b8 */ uint8 r5 = (r8 >> (8-5)) << R_RGB565_OFFSET; uint8 g6 = (g8 >> (8-6)) << G_RGB565_OFFSET; uint8 b5 = (b8 >> (8-5)); uint16 rgb565 = (r5|g6|b5); uint16 rgb565_from_sdl = get_pixel_rgb565_from_sdl (...); if (rgb565 == rgb565_from_sdl) { /* same value */ } ... - Joni Valtanen
- Previous message: [maemo-developers] Nokia SDL color format for pixels
- Next message: [maemo-developers] Nokia SDL color format for pixels
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]