[SDL] Pixel byte manipulation question.
Gabriele Greco
gabriele.greco at darts.it
Wed Oct 3 09:22:32 PDT 2007
Paul Duffy wrote:
> Gack. I'll have to see if the screen blitting functions would accept
> such a format, I'd rather avoid having to check the dest/source masks
> every time. If the format is reasonably predictable then the worst I
> have to do is use some ifdefs to use the appropriate formatting per
> platform rather than having to use runtime detection. I'm mainly trying
> to avoid doing anything unnecessary that would slow things down.
>
The format is not predictable, at least if you don't enforce it and
force SDL do the conversion (this is an option, but will slow down
things if you don't have to blit MANY pixels one by one). If you blit on
a DisplayFormatted() surface you should consider Rmask, Gmask... Rshift,
Bshift... to do your pixel blitting.
You can find big endian or little endian pixel modes both in big and
little endian machines, this give already 4 different possibility for
EVERY pixel mode, so you got at least 4 different RGBA cases.
Then you have to consider RGB and 15/16bit modes, and consider also that
most system can promote 15bit to 16bit, 16bit to 32bit, 24bit to
32bit.... and so on.
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 :)
--
Bye,
Gabry
More information about the SDL
mailing list