summaryrefslogtreecommitdiff
path: root/packages/gtk+
diff options
context:
space:
mode:
authorKoen Kooi <koen@openembedded.org>2007-02-14 07:19:19 +0000
committerKoen Kooi <koen@openembedded.org>2007-02-14 07:19:19 +0000
commit3278d5079ad2d86a97bb495e3c75f91494ebf690 (patch)
treefa6510d21473d7fdabca3a795e6194d2f2f203bf /packages/gtk+
parent8dc182e9960996f5010edcc598fbfaa8a12faceb (diff)
pixop-test: adds new enhanced version written by Rob Taylor
Diffstat (limited to 'packages/gtk+')
-rw-r--r--packages/gtk+/pixops-test.bb2
-rw-r--r--packages/gtk+/pixops-test/pixops-test.c51
2 files changed, 43 insertions, 10 deletions
diff --git a/packages/gtk+/pixops-test.bb b/packages/gtk+/pixops-test.bb
index b65f700a16..79bc33a04f 100644
--- a/packages/gtk+/pixops-test.bb
+++ b/packages/gtk+/pixops-test.bb
@@ -1,7 +1,7 @@
DESCRIPTION = "Productive gtk+ devel prodder"
DEPENDS = "gtk+"
-PR = "r1"
+PR = "r2"
inherit pkgconfig
diff --git a/packages/gtk+/pixops-test/pixops-test.c b/packages/gtk+/pixops-test/pixops-test.c
index 33a11263de..f8906dfc42 100644
--- a/packages/gtk+/pixops-test/pixops-test.c
+++ b/packages/gtk+/pixops-test/pixops-test.c
@@ -1,35 +1,68 @@
#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, *ret;
- pixbuf = gdk_pixbuf_new_from_file("/usr/share/pixop-test/gtk-logo-rgb.gif", NULL);
+ 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);
- int i;
-
- for (i = 1; i <= 100 ; i++) {
- ret = gdk_pixbuf_scale_simple (pixbuf, 800, 600, GDK_INTERP_BILINEAR);
- ret = gdk_pixbuf_scale_simple (pixbuf, 300, 400, GDK_INTERP_BILINEAR);
+ 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);
- gtk_main ();
-
g_print ("time spent scaling (in seconds): %lf\n", total_seconds );
return 0;