[SDL] Pixel byte manipulation question.
matt hull
mattmatteh at mac.com
Tue Oct 2 11:33:31 PDT 2007
On Oct 2, 2007, at 10:45 AM, Paul Duffy wrote:
>> the mask tell you what part of the uint32 is RGBA. it is not the
>> same on all machines, it is determined by the graphics hardwhere. i
>> test my app on 3 different machines and each have a different RGBA
>> mask.
>
> That's not the part I'm wondering about, I know the mask /order/ is
> different for different computers (and actually different file formats
> on load) and that at some point the bytes have to be ordered in a way
> the hardware expects.
>
> What I need to know is, can I expect the mask and colorkey data be in
> the rightmost portion of a Uint32 _regardless_of_platform_? I know the
> order could be RGBA/BGRA/ARGB/ABGR or 565/3553/RGB/BGR. However, some
> of the data is stored with bitshifting which doesn't give a monkeys
> about Endianness and just puts the bits in a specific position, eg.
> the
> rightmost bit, whether that's the highest, lowest or middling bit
> which
> means that regardless of the ordering, some data will end up in the
> same bytes of a Uint32 no matter what platform is being used.
>
> So, if a 24 but value is being stored, is it stored in the first or
> last 24 bits of the 32 bit integer? If it's 16 bits, is it stored in
> the higher or lower half? Is an 8 bit palette value stored in the
> first
> or last byte of the (still) 32 bit colorkey?
>
> Really, it's not a question of hardware, it's a question of how SDL
> handles data internally and whether this is consistent.
i am not an SDL developer, only a user, so perhaps someone else could
answer better than i. i believe SDL uses a pixel format that is
closest to the hardware or the graphics driver being used. there
should be a list of available graphics drivers for what ever
platform. i suppose this answer doesnt help you any more than the last.
i am not sure how SDL handles internal surfaces.
are you writing an application with SDL or trying to understand it
more ?
you could look at the source.
matt
More information about the SDL
mailing list