[oe-commits] org.oe.dev pixop-test: adds new enhanced version written by Rob Taylor

koen commit openembedded-commits at lists.openembedded.org
Wed Feb 14 07:21:46 UTC 2007


pixop-test: adds new enhanced version written by Rob Taylor

Author: koen at openembedded.org
Branch: org.openembedded.dev
Revision: eb2aaa8111ec4c420d768c8f835d142e4dd9b68f
ViewMTN: http://monotone.openembedded.org/revision.psp?id=eb2aaa8111ec4c420d768c8f835d142e4dd9b68f
Files:
1
packages/gtk+/pixops-test/pixops-test.c
packages/gtk+/pixops-test.bb
Diffs:

#
# mt diff -r50c9ee81517d5a1c32a7a7afe7a00793aabceb33 -reb2aaa8111ec4c420d768c8f835d142e4dd9b68f
#
# 
# 
# patch "packages/gtk+/pixops-test/pixops-test.c"
#  from [c62b766b06b6b3c5a153f85c0b0e67b49ec56f76]
#    to [ad7d575013fb63e0de5aba7d233ad77e87dbcc95]
# 
# patch "packages/gtk+/pixops-test.bb"
#  from [0a48d57805ba35d8af50d7d0269dd9752dc3dfce]
#    to [9cd3e6537f04b78bd3350f219d3428d00336c483]
# 
============================================================
--- packages/gtk+/pixops-test/pixops-test.c	c62b766b06b6b3c5a153f85c0b0e67b49ec56f76
+++ packages/gtk+/pixops-test/pixops-test.c	ad7d575013fb63e0de5aba7d233ad77e87dbcc95
@@ -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;
============================================================
--- packages/gtk+/pixops-test.bb	0a48d57805ba35d8af50d7d0269dd9752dc3dfce
+++ packages/gtk+/pixops-test.bb	9cd3e6537f04b78bd3350f219d3428d00336c483
@@ -1,7 +1,7 @@ DEPENDS = "gtk+"
 DESCRIPTION = "Productive gtk+ devel prodder"
 DEPENDS = "gtk+"
 
-PR = "r1"
+PR = "r2"
 
 inherit pkgconfig
 






More information about the Openembedded-commits mailing list