summaryrefslogtreecommitdiff
path: root/test/composite-test.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/composite-test.c')
-rw-r--r--test/composite-test.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/test/composite-test.c b/test/composite-test.c
index d6596f49..388c8e64 100644
--- a/test/composite-test.c
+++ b/test/composite-test.c
@@ -1,10 +1,9 @@
#include <stdlib.h>
#include <stdio.h>
#include "pixman.h"
-
#include <gtk/gtk.h>
-static GdkPixbuf *
+GdkPixbuf *
pixbuf_from_argb32 (uint32_t *bits,
int width,
int height,
@@ -15,20 +14,36 @@ pixbuf_from_argb32 (uint32_t *bits,
int p_stride = gdk_pixbuf_get_rowstride (pixbuf);
guint32 *p_bits = (guint32 *)gdk_pixbuf_get_pixels (pixbuf);
int w, h;
-
+
for (h = 0; h < height; ++h)
{
for (w = 0; w < width; ++w)
{
uint32_t argb = bits[h * stride + w];
- guint32 rgba;
-
- rgba = (argb << 8) | (argb >> 24);
-
- p_bits[h * (p_stride / 4) + w] = rgba;
+ guint r, g, b, a;
+ char *pb = p_bits;
+
+ pb += h * p_stride + w * 4;
+
+ r = (argb & 0x00ff0000) >> 16;
+ g = (argb & 0x0000ff00) >> 8;
+ b = (argb & 0x000000ff) >> 0;
+ a = (argb & 0xff000000) >> 24;
+
+ if (a)
+ {
+ r = (r * 255) / a;
+ g = (g * 255) / a;
+ b = (b * 255) / a;
+ }
+
+ pb[0] = r;
+ pb[1] = g;
+ pb[2] = b;
+ pb[3] = a;
}
}
-
+
return pixbuf;
}