Home Products Download Order Contacts


Subject: Re: Help with blit bug!

> Yes, RGB565_32_A128 == 0xF7DEF7DE. If the problem is endianess, given
> the code I have is there an efficient way to handle it? Thanks.

If a 2-byte word is stored as AB in one convention then it is stored BA
in the other. Likewise, if a 4-byte doubleword is stored as ABCD in one
convention then it is stored DCBA in the other.

You handle a doubleword at a time, but actually it consists of 2
separate words. Thus a conversion needs to swap the word bytes
separately, for example ABCD -> BADC.

Assume you have incompatible endians. Then you would write something

uint32 data = getSomeData();
// Convert to device endian
uint32 correctData = ((data & 0xFF00FF00) >> 8) + ((data & 0x00FF00FF)
<< 8)
// Do calculations
// Convert back to data endian
data = ((correctData & 0xFF00FF00) >> 8) + ((correctData & 0x00FF00FF)
<< 8)

If a conversion is needed depends on the endianness of the data as well
as the endianness of the device.

Note, the same conversion works in both directions (from little-endian
to high-endian and vice versa) because it is symmetric.

Kalle Rutanen


View All Messages in comp.graphics.algorithms

Help with blit bug! =>Re: Help with blit bug! =>Re: Help with blit bug! =>


Copyright 2006 WatermarkFactory.com. All Rights Reserved.