[Pixman] image byte order?

Gerd Hoffmann kraxel at redhat.com
Fri Oct 12 00:47:47 PDT 2012


On 10/11/12 15:34, Jonathan Morton wrote:
> On Thu, 11 Oct 2012 12:56:57 +0200, Gerd Hoffmann <kraxel at redhat.com>
> wrote:
>> How are the 32bpp image formats like PIXMAN_x8r8g8b8 defined to look
>> like in memory?  Fixed format, i.e. always the same no matter whenever
>> the box is big or little endian?  Or native endian?
> 
> Native endian.  The format is defined in terms of bitfields in a 32-bit
> integer.

So PIXMAN_x8r8g8b8 @ bigendian box equals PIXMAN_b8g8r8x8 @ little
endian box, correct?

> The 16-bit formats (such as r5g6b5) are also defined
> similarly.

Ok.

> The 24-bit formats are not.

So PIXMAN_r8g8b8 has the red byte first no matter what the endian is,
correct?

> So to convert to or from a particular on-disk image format, or one
> which is defined in terms of bytes (as OpenGL does), you could use
> ntohl() and htonl() from the sockets subsystem.

Or pick the format depending on the machine byteorder when passing the
pixel blob as-is to pixman_image_create_bits (well, for 32-bit formats
at least, the 16-bit ones don't have a green bitfield any more when
byteswapped ...).

cheers,
  Gerd



More information about the Pixman mailing list