From 14b090e5667f84a6b2de192b80053f9e068044df Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Mon, 27 Apr 2009 12:09:04 +0200 Subject: [PATCH] image: fix conversion on different endianness (FS#504) Signed-off-by: Julien Danjou --- image.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/image.c b/image.c index 13994fe3..04d3389d 100644 --- a/image.c +++ b/image.c @@ -100,12 +100,21 @@ image_compute(image_t *image) for(i = 0; i < size; i++, dataimg += 4) { +#if AWESOME_IS_BIG_ENDIAN + dataimg[0] = (data[i] >> 24) & 0xff; /* A */ + /* cairo wants pre-multiplied alpha */ + alpha = dataimg[0] / 255.0; + dataimg[1] = ((data[i] >> 16) & 0xff) * alpha; /* R */ + dataimg[2] = ((data[i] >> 8) & 0xff) * alpha; /* G */ + dataimg[3] = (data[i] & 0xff) * alpha; /* B */ +#else dataimg[3] = (data[i] >> 24) & 0xff; /* A */ /* cairo wants pre-multiplied alpha */ alpha = dataimg[3] / 255.0; dataimg[2] = ((data[i] >> 16) & 0xff) * alpha; /* R */ dataimg[1] = ((data[i] >> 8) & 0xff) * alpha; /* G */ dataimg[0] = (data[i] & 0xff) * alpha; /* B */ +#endif } }