[SDL] Pixel byte manipulation question.
Paul Duffy
odubtaig at yahoo.co.uk
Thu Oct 4 10:36:17 PDT 2007
On Wed, 2007-10-03 at 18:17 -0500, matt hull wrote:
> that is an incorrect assumption. i tried that myself and had to fix
> my application. you need to use the mask. the system endianness
> doesnt tell all.
>
Actually, as I'm entirely using source data which has already had its
ordering defined by the RGB mask at this stage that pretty much is the
be-all and end-all. With the destination RGB mask being defined by the
source mask and the ordering in which the colorkey is stored being
defined by the RGB mask, I can very much rely on not having to worry
about reordering bits or bytes at this stage. My main angle here is
image manipulation which will involve a lot of pixel copying and a lot
of clearing with the colorkey.
Having looked through various functions for SDL, it's seems clear that
SDL itself expects any mask combination for any pixel value of less than
32 bits to be in the LSB and upwards and that any attempt to have an RGB
mask starting at the MSB will be problematic within SDL itself.
I'm also getting the impression from SDL_FillRect that the ordering of
the bytes per pixel in the pixels array is entirely dependent on the
endianness of the system (in that the LSB of the RGBA mask in a little
endian system will always be first in a 4 bit pixel in a surface and so
on) so what I _don't_ wan't to do is do any byte swapping when doing a
colour fill (although all that stuff re. hardware surfaces and 4 or 1
bit pixels can go as I won't be using any). I can also see some cases
for optimising over SDL_memset4.
> how often are you changing your pixels ? is it possible you could
> set up your palette or surface during an initialization?
>
In some cases yes, but there are going to be cases in which I'm going to
be blitting at a given frame-rate which means that functions such as the
default SDL putpixel (as seen in the docs) are going to slow things down
as they check the colour depth and RGB mask per pixel while I would
prefer to do so per frame.
As above with the rectangle filling I already have some prior knowledge
of what I'm going to be dealing with so there's a lot of things I don't
need to check, or check as often, and there are places I can optimise
for a slightly less broad support of platforms.
___________________________________________________________
The all-new Yahoo! Mail goes wherever you go - free your email address from your Internet provider. http://uk.docs.yahoo.com/nowyoucan.html
More information about the SDL
mailing list