[SDL] Pixel byte manipulation question.
Paul Duffy
odubtaig at yahoo.co.uk
Wed Oct 3 11:14:15 PDT 2007
On Wed, 2007-10-03 at 18:22 +0200, Gabriele Greco wrote:
> I think that to do things the right way you will need a switch with so
> many "case" statements than the shift performance penality will be
> acceptable :)
>
So, looking at functions like MapRGB et al and assuming that I'm
blitting to a 24bit surface with unknown RGB order, also assuming that
I'm not caring about overwriting pixels I'm going to be writing to in a
second (because I'm clearing by colorkey) and that I've taken into
account that the last few pixels of a line need to be dealt with per
byte in case the number of pixels is even/odd:
Could I use *(Uint32 *)pixeladdress = colorkey << 8 ?
Would *(Uint32 *)pixeladdress = colorkey << 16 | colorkey work for 16
bit surfaces?
I'm mostly assuming that bitshifting will work in the same way on a
datablock larger than a byte regardless of endianness as it seems to be
treated this way in at least parts of SDL (the byte order may change but
it's all moved to the same place by the same method as far as I can
tell) and I'm hoping it holds true across the board as there wouldn't be
a single branch required if this is so.
Maybe I'm being obtuse, but I've worked so far only on Intel hardware.
___________________________________________________________
All New Yahoo! Mail Tired of Vi at gr@! come-ons? Let our SpamGuard protect you. http://uk.docs.yahoo.com/nowyoucan.html
More information about the SDL
mailing list