[maemo-developers] SDL, pixel format and little endian issue
From: Frantisek Dufka dufkaf at seznam.czDate: Mon Sep 1 16:16:46 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 ]
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). Frantisek
- 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 ]