aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--VERSION2
-rw-r--r--src/backend_cairo.c10
2 files changed, 7 insertions, 5 deletions
diff --git a/VERSION b/VERSION
index 1736ba3..fead489 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.1.1077
+0.1.1079
diff --git a/src/backend_cairo.c b/src/backend_cairo.c
index 877266b..af002ba 100644
--- a/src/backend_cairo.c
+++ b/src/backend_cairo.c
@@ -730,15 +730,17 @@ d2tk_cairo_process(void *data, d2tk_core_t *core, const d2tk_com_t *com,
// bitswap and premultiply pixel data
for(unsigned i = 0; i < W*H*sizeof(uint32_t); i += sizeof(uint32_t))
{
+ // get alpha channel
const uint8_t a = pixels[i+3];
+
+ // premultiply with alpha channel
const uint8_t r = ( (uint16_t)pixels[i+0] * a ) >> 8;
const uint8_t g = ( (uint16_t)pixels[i+1] * a ) >> 8;
const uint8_t b = ( (uint16_t)pixels[i+2] * a ) >> 8;
- pixels[i+0] = b;
- pixels[i+1] = g;
- pixels[i+2] = r;
- pixels[i+3] = a;
+ // merge and byteswap to correct endianness
+ uint32_t *pix = (uint32_t *)&pixels[i];
+ *pix = (a << 24) | (r << 16) | (g << 8) | b;
}
cairo_surface_t *surf = cairo_image_surface_create_for_data(pixels,