[maemo-developers] [maemo-developers] Nokia SDL color format for pixels
From: Michael Stepanov michael at stepanoff.orgDate: Fri Aug 29 11:54:16 EEST 2008
- Previous message: [maemo-developers] Nokia SDL color format for pixels
- Next message: vpn on the tablet vs Nokia intranet
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Found the problem. It's Big/Little Endian issue. It seems that SDL pixel format doesn't take into account the byte order for *[RGBA]shift: SDL_PixelFormat * PF = screen->format; How can I modify the statement: *PixelSrc = (ColorToReplace.R() << PF->Rshift) | (ColorToReplace.G() << PF->Gshift) | (ColorToReplace.B() << PF->Bshift); To use correct shift for little endian? On Fri, Aug 29, 2008 at 10:44 AM, Michael Stepanov <michael at stepanoff.org>wrote: > Thanks a lot, guys, for your help. Finally I managed to get correct RGB > from the 16bit pixel using SDL_GetRGB. First I get a pixel and then retrieve > RGB from it: > > Uint8 red, green, blue; > Uint32 pixel; > > for(int y = 0; y < 480; y++) > { > for(int x = 0; x < 640; x++) > { > pixel = getpixel(surface, x, y); > SDL_GetRGB((Uint32)pixel, surface->format, &red, &green, &blue); > } > } > > But now I have another problem. There is a transformation of color: > > PixelSrc = (ColorToReplace.R() << PF->Rshift) | (ColorToReplace.G() << > PF->Gshift) | (ColorToReplace.B() << PF->Bshift); > > Where ColorToReplace is (255,102,155) > > But after that transformation it becomes (255, 252, 7). Could somebody tell > me where is a mistake? > > TIA > > P. S. Sorry for not clever questions. I don't have a big C++ and SDL > practice. > > -- > Cheers, > Michael > -- Cheers, Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.maemo.org/pipermail/maemo-developers/attachments/20080829/360b1a9d/attachment.htm
- Previous message: [maemo-developers] Nokia SDL color format for pixels
- Next message: vpn on the tablet vs Nokia intranet
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]