diff options
author | Søren Sandmann Pedersen <ssp@redhat.com> | 2012-04-02 15:16:18 -0400 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@redhat.com> | 2012-04-02 15:25:00 -0400 |
commit | 87ecec8d72be4106358e843a1e7a907b0e814f7f (patch) | |
tree | cf73d7f673320a062a634bbdec050eeccf114f9c /demos | |
parent | d1ec1467f607c21a4d8b445eab5465ca60a12a97 (diff) | |
download | pixman-87ecec8d72be4106358e843a1e7a907b0e814f7f.tar.gz |
gtk-utils.c: In pixbuf_from_argb32() use a8r8g8b8_to_rgba_np()
Instead of inlining a copy of that functionality.
Diffstat (limited to 'demos')
-rw-r--r-- | demos/Makefile.am | 6 | ||||
-rw-r--r-- | demos/gtk-utils.c | 41 |
2 files changed, 11 insertions, 36 deletions
diff --git a/demos/Makefile.am b/demos/Makefile.am index 6049090..a664d93 100644 --- a/demos/Makefile.am +++ b/demos/Makefile.am @@ -6,7 +6,7 @@ AM_LDFLAGS = $(OPENMP_CFLAGS) LDADD = $(top_builddir)/pixman/libpixman-1.la -lm $(GTK_LIBS) $(PNG_LIBS) INCLUDES = -I$(top_srcdir)/pixman -I$(top_builddir)/pixman $(GTK_CFLAGS) $(PNG_CFLAGS) -GTK_UTILS = gtk-utils.c gtk-utils.h +GTK_UTILS = gtk-utils.c gtk-utils.h ../test/utils.c ../test/utils.h DEMOS = \ clip-test \ @@ -30,8 +30,8 @@ clip_in_SOURCES = clip-in.c $(GTK_UTILS) trap_test_SOURCES = trap-test.c $(GTK_UTILS) screen_test_SOURCES = screen-test.c $(GTK_UTILS) convolution_test_SOURCES = convolution-test.c $(GTK_UTILS) -radial_test_SOURCES = radial-test.c ../test/utils.c ../test/utils.h $(GTK_UTILS) -tri_test_SOURCES = tri-test.c ../test/utils.c ../test/utils.h $(GTK_UTILS) +radial_test_SOURCES = radial-test.c $(GTK_UTILS) +tri_test_SOURCES = tri-test.c $(GTK_UTILS) checkerboard_SOURCES = checkerboard.c $(GTK_UTILS) noinst_PROGRAMS = $(DEMOS) diff --git a/demos/gtk-utils.c b/demos/gtk-utils.c index b321989..1ff89eb 100644 --- a/demos/gtk-utils.c +++ b/demos/gtk-utils.c @@ -1,5 +1,6 @@ #include <gtk/gtk.h> #include <config.h> +#include "../test/utils.h" #include "gtk-utils.h" GdkPixbuf * @@ -13,45 +14,19 @@ pixbuf_from_argb32 (uint32_t *bits, 8, width, height); 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 / 4) + w]; - guint r, g, b, a; - char *pb = (char *)p_bits; - - pb += h * p_stride + w * 4; - - r = (argb & 0x00ff0000) >> 16; - g = (argb & 0x0000ff00) >> 8; - b = (argb & 0x000000ff) >> 0; - a = has_alpha? (argb & 0xff000000) >> 24 : 0xff; + int i; - if (a) - { - r = (r * 255) / a; - g = (g * 255) / a; - b = (b * 255) / a; - } + for (i = 0; i < height; ++i) + { + uint32_t *src_row = &bits[i * (stride / 4)]; + uint32_t *dst_row = p_bits + i * (p_stride / 4); - if (r > 255) r = 255; - if (g > 255) g = 255; - if (b > 255) b = 255; - - pb[0] = r; - pb[1] = g; - pb[2] = b; - pb[3] = a; - } + a8r8g8b8_to_rgba_np (dst_row, src_row, width); } - + return pixbuf; } - static gboolean on_expose (GtkWidget *widget, GdkEventExpose *expose, gpointer data) { |