[maemo-developers] SDL, pixel format and little endian issue
From: Michael Stepanov michael at stepanoff.orgDate: Mon Sep 1 22:21:54 EEST 2008
- Previous message: SDL, pixel format and little endian issue
- Next message: SDL, pixel format and little endian issue
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Just fixed issue with wrong color of pixels by creating 16bit pixel instead of 32bit: Uint16 PlutoPixelDest = ((ReplacementColor.R() >> PF->Rloss) << PF->Rshift) + ((ReplacementColor.G() >> PF->Gloss) << PF->Gshift) + ((ReplacementColor.B() >> PF->Bloss) << PF->Bshift); where ReplacementColor is structure with 32bit RGB. On Mon, Sep 1, 2008 at 4:27 PM, Michael Stepanov <michael at stepanoff.org>wrote: > > > On Mon, Sep 1, 2008 at 4:16 PM, Frantisek Dufka <dufkaf at seznam.cz> wrote: > >> Michael Stepanov wrote: >> >>> Hi, >>> >>> I have a SDL application where I have to replace color of specified >>> pixels. So, I have a color in RGB representation and convert it to the pixel >>> color using that approach: >>> >>> Uint32 PixelSrc = (0 << PF->Rshift) | (128 << PF->Gshift) | (192 << >>> PF->Bshift); >>> >>> But as result I get color 0x10c0 instead of 0x0080C0. Why it's happens? >>> >> >> You did not mention pixel format, if you use device native 16 bit format >> (RGB565?) you cannot use values like 128 or 192 since it will overflow 5 or >> 6 bits. Also you should do proper masking. >> >> Moreover, I found following values for Xshift for little endian: >>> >>> const int rshift = 0, gshift = 8, bshift = 16, ashift = 24; >>> Uini32 PixelDest = (0 << rshift) | (128 << gshift) | (192 << bshift); >>> >>> But the byte order is different. I get 0xc08000 but it should be >>> 0x0080c0. >>> >> >> 00c08000 seems fine to me for 0<<0 | 0x80<<8 |0xC0<<16. >> >> I think you should add a bit more of your example code and also tell us >> what you want to do (and maybe even why). > > > Ok, there is an SDL application which was ported from x86 to Nokia. The > issue with color is following. The application finds some icons on the > picture (they are all pink - 255, 102, 255) and replace them by proper color > - yellow, red, gray etc. The replacement colors are 32bit but Nokia uses > 16bit as you already mentioned. So, I found the way how to compare pink > color with actual color of specified pixel: > > SDL_GetRGB((Uint32)Pixel, m_pScreenImage->format, &red, &green, &blue); > > where Pixel is retrieved from the surface in the loop. > > But now I have to fill pink pixel by specified color. And as I understand I > should convert that color from 32bit to 16bit? How can I do it? > > Maybe that's why Xshift works wrongly because I try to use 32bit color > definition with 16bit surface? > > >> >> >> Frantisek >> > > > > -- > Cheers, > Michael > -- Cheers, Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.maemo.org/pipermail/maemo-developers/attachments/20080901/f79e5fa6/attachment.htm
- Previous message: SDL, pixel format and little endian issue
- Next message: SDL, pixel format and little endian issue
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]