[cairo] byte data storage format
dventura7 at gmail.com
Wed Feb 11 09:07:25 PST 2009
I figured it was something like this, and for what I'm doing it is easy
enough to swap the bytes. However, as pointed out here, this will be very
platform dependent. I'm a little surprised that cairo does not have a
pixel_c (or possibly a set of them -- one for each format) that abstracts
the image data away from the platform.
Maybe I'm just being dumb (being new to cairo and new to this image stuff in
general). Is there a clean way to access pixel-level image_surface data
that is not going to run into platform issues? Hopefully this isn't too
dumb of a question...
On Wed, Feb 11, 2009 at 4:21 AM, Bill Spitzak <spitzak at thefoundry.co.uk>wrote:
> Gerdus van Zyl wrote:
> > It's in BGRA format. I think it's platform and not architecture
> > specific since windows at least works with BGR. And the reason for
> > that is I guess performance.
> The bytes are in the order BGRA:
> unsigned char* p = data;
> p == B, p == G, p == B, p == A
> Sometimes this is called ARGB32 (and sometimes just ARGB), because this
> is the order the bytes appear if you look at a 32-bit word:
> unsigned int* p = data;
> p == (A<<24)+(R<<16)+(B<<8)+(B<<0);
> We are pretty much stuck with this, as Windows used ARGB32 to represent
> colors, so all the graphics cards made that the fastest format.
> It appears on big-endian machines like PowerPC, the native data is
> *still* ARGB32, but that means the bytes are in the reversed order ARGB.
> This is because the 32-bit bus that connects to the graphics is swapped
> around so that 32-bit integers and floats look the same to the graphics
> cards. I am not sure about this, somebody please correct me if wrong.
> However if this is true it is probably best to not use bytes, but use
> words to address your image data at all times, so that your code is
> portable to big-endian.
> Bill Spitzak, Senior Software Engineer
> The Foundry, 1 Wardour Street, London, W1D 6PA, UK
> Tel: +44 (0)20 7434 0449 * Fax: +44 (0)20 7434 1550 * Web:
> The Foundry Visionmongers Ltd * Registered in England and Wales No: 4642027
> cairo mailing list
> cairo at cairographics.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cairo