diff options
author | Denys Dmytriyenko <denis@denix.org> | 2009-03-17 14:32:59 -0400 |
---|---|---|
committer | Denys Dmytriyenko <denis@denix.org> | 2009-03-17 14:32:59 -0400 |
commit | 709c4d66e0b107ca606941b988bad717c0b45d9b (patch) | |
tree | 37ee08b1eb308f3b2b6426d5793545c38396b838 /recipes/gtk+/pixops-test/pixops-test.c | |
parent | fa6cd5a3b993f16c27de4ff82b42684516d433ba (diff) |
rename packages/ to recipes/ per earlier agreement
See links below for more details:
http://thread.gmane.org/gmane.comp.handhelds.openembedded/21326
http://thread.gmane.org/gmane.comp.handhelds.openembedded/21816
Signed-off-by: Denys Dmytriyenko <denis@denix.org>
Acked-by: Mike Westerhof <mwester@dls.net>
Acked-by: Philip Balister <philip@balister.org>
Acked-by: Khem Raj <raj.khem@gmail.com>
Acked-by: Marcin Juszkiewicz <hrw@openembedded.org>
Acked-by: Koen Kooi <koen@openembedded.org>
Acked-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>
Diffstat (limited to 'recipes/gtk+/pixops-test/pixops-test.c')
-rw-r--r-- | recipes/gtk+/pixops-test/pixops-test.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/recipes/gtk+/pixops-test/pixops-test.c b/recipes/gtk+/pixops-test/pixops-test.c new file mode 100644 index 0000000000..f8906dfc42 --- /dev/null +++ b/recipes/gtk+/pixops-test/pixops-test.c @@ -0,0 +1,69 @@ +#include <gtk/gtk.h> +#include <gdk-pixbuf/gdk-pixbuf.h> +#include <stdlib.h> + +static gdouble total_seconds = 0.0; + +/* randomly colour each pixel */ +static void +fill_pixbuf (GdkPixbuf *buf) +{ + int width, height, rowstride, n_channels; + int x,y,n; + guchar *pixels, *p; + + g_assert (gdk_pixbuf_get_bits_per_sample (buf) == 8); + + n_channels = gdk_pixbuf_get_n_channels (buf); + width = gdk_pixbuf_get_width (buf); + height = gdk_pixbuf_get_height (buf); + rowstride = gdk_pixbuf_get_rowstride (buf); + pixels = gdk_pixbuf_get_pixels (buf); + + for (x=0; x<width; x++) { + for (y=0; y<height; y++) { + p = pixels + (y*rowstride) + (x*n_channels); + for (n=0; n<n_channels; n++) { + p[n] = (random()*255)/RAND_MAX; + } + } + } +} + +int +main (int argc, char **argv) +{ + GTimer *timer; + int i,j; + + gtk_init (&argc, &argv); + + + GdkPixbuf *pixbuf[4], *ret; + pixbuf[0] = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 400, 600); + pixbuf[1] = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 40, 60); + pixbuf[2] = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, 400, 600); + pixbuf[3] = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, 40, 60); + + for (j=0; j<4; j++) + fill_pixbuf (pixbuf[j]); + + timer = g_timer_new (); + g_timer_start (timer); + + for (i = 0; i < 10 ; i++) { + for (j=0; j<4; j++) { + ret = gdk_pixbuf_scale_simple (pixbuf[j], 700, 900, GDK_INTERP_BILINEAR); + gdk_pixbuf_unref (ret); + ret = gdk_pixbuf_scale_simple (pixbuf[j], 20, 50, GDK_INTERP_BILINEAR); + gdk_pixbuf_unref (ret); + } + } + g_timer_stop (timer); + + total_seconds += g_timer_elapsed (timer, NULL); + + g_print ("time spent scaling (in seconds): %lf\n", total_seconds ); + + return 0; +} |