[maemo-commits] [maemo-commits] r18701 - in projects/haf/trunk/hildon-thumbnail: . daemon/plugins thumbs

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Thu Jun 11 13:15:45 EEST 2009
Author: pvanhoof
Date: 2009-06-11 13:15:40 +0300 (Thu, 11 Jun 2009)
New Revision: 18701

Modified:
   projects/haf/trunk/hildon-thumbnail/ChangeLog
   projects/haf/trunk/hildon-thumbnail/daemon/plugins/gdkpixbuf-plugin.c
   projects/haf/trunk/hildon-thumbnail/daemon/plugins/pixbuf-io-loader.c
   projects/haf/trunk/hildon-thumbnail/thumbs/hildon-thumbnail-obj.c
Log:
2009-06-11  Philip Van Hoof  <philip at codeminded.be>

        * thumbs/hildon-thumbnail-obj.c
        * daemon/plugins/gdkpixbuf-plugin.c
        * daemon/plugins/pixbuf-io-loader.c: Sanity checks



Modified: projects/haf/trunk/hildon-thumbnail/ChangeLog
===================================================================
--- projects/haf/trunk/hildon-thumbnail/ChangeLog	2009-06-11 07:28:12 UTC (rev 18700)
+++ projects/haf/trunk/hildon-thumbnail/ChangeLog	2009-06-11 10:15:40 UTC (rev 18701)
@@ -1,3 +1,9 @@
+2009-06-11  Philip Van Hoof  <philip at codeminded.be>
+
+	* thumbs/hildon-thumbnail-obj.c
+	* daemon/plugins/gdkpixbuf-plugin.c
+	* daemon/plugins/pixbuf-io-loader.c: Sanity checks
+
 2009-06-10  Philip Van Hoof  <philip at codeminded.be>
 
 	* daemon/hildon-thumbnail-plugin.c: No need to copy the list here

Modified: projects/haf/trunk/hildon-thumbnail/daemon/plugins/gdkpixbuf-plugin.c
===================================================================
--- projects/haf/trunk/hildon-thumbnail/daemon/plugins/gdkpixbuf-plugin.c	2009-06-11 07:28:12 UTC (rev 18700)
+++ projects/haf/trunk/hildon-thumbnail/daemon/plugins/gdkpixbuf-plugin.c	2009-06-11 10:15:40 UTC (rev 18701)
@@ -45,12 +45,18 @@
 
 #include <hildon-thumbnail-plugin.h>
 
+#define HAVE_OSSO
+
 #ifdef HAVE_OSSO
 #define MAX_SIZE	(1024*1024*5)
 #define MAX_PIX		(5000000)
+#define MAX_W		(5000)
+#define MAX_H		(5000)
 #else
 #define MAX_SIZE	(1024*1024*100)
 #define MAX_PIX		(5000000*(100/5))
+#define MAX_W		(10000)
+#define MAX_H		(10000)
 #endif
 
 GdkPixbuf *
@@ -65,6 +71,7 @@
 my_gdk_pixbuf_new_from_stream (GInputStream  *stream,
 			    GCancellable  *cancellable,
 			       guint max_pix,
+			       guint max_w, guint max_h,
 			    GError       **error);
 
 static gchar **supported = NULL;
@@ -124,9 +131,33 @@
 		guint width; guint height;
 		guint rowstride; 
 		gboolean err_file = FALSE;
+/*		gchar *path; */
 
 		file = g_file_new_for_uri (uri);
+/*
+		path = g_file_get_path (file);
 
+		if (path) {
+			gchar *up = g_utf8_strup (path, -1);
+			if (g_str_has_suffix (up, "GIF")) {
+				gchar buffer[16];
+				FILE *f = fopen (path, "r");
+				if (f) {
+					if (fread (buffer, 16, 1, f) == 1) {
+						guint w = 0, h = 0;
+						w |= buffer[6];
+						w |= buffer[7];
+						h |= buffer[8];
+						h |= buffer[9];
+						printf ("%dx%d\n", w, h);
+					}
+					fclose (f);
+				}
+			}
+			g_free (up);
+			g_free (path);
+		}
+*/
 		info = g_file_query_info (file, G_FILE_ATTRIBUTE_TIME_MODIFIED ","
 					        G_FILE_ATTRIBUTE_STANDARD_SIZE,
 					  G_FILE_QUERY_INFO_NONE,
@@ -261,7 +292,8 @@
 			int a, b;
 
 			GdkPixbuf *pixbuf1 = my_gdk_pixbuf_new_from_stream (G_INPUT_STREAM (stream), 
-									    NULL, MAX_PIX, &nerror);
+									    NULL, MAX_PIX, 
+									    MAX_W, MAX_H, &nerror);
 
 			if (nerror) {
 				if (pixbuf1)

Modified: projects/haf/trunk/hildon-thumbnail/daemon/plugins/pixbuf-io-loader.c
===================================================================
--- projects/haf/trunk/hildon-thumbnail/daemon/plugins/pixbuf-io-loader.c	2009-06-11 07:28:12 UTC (rev 18700)
+++ projects/haf/trunk/hildon-thumbnail/daemon/plugins/pixbuf-io-loader.c	2009-06-11 10:15:40 UTC (rev 18701)
@@ -31,7 +31,7 @@
 #define LOAD_BUFFER_SIZE 65536
 
 typedef struct {
-	guint max_pix;
+	guint max_pix, max_w, max_h;
 	gboolean stop;
 } LoadInfo;
 
@@ -115,13 +115,24 @@
 {
 	LoadInfo *linfo = data;
 
-	if (linfo->max_pix == 0) {
+	if (linfo->max_pix == 0 &&
+	    linfo->max_w == 0 &&
+	    linfo->max_h == 0) {
 		return;
 	}
 
 	if (width * height > linfo->max_pix) {
 		linfo->stop = TRUE;
 	}
+
+	if (width > linfo->max_w) {
+		linfo->stop = TRUE;
+	}
+
+	if (height > linfo->max_h) {
+		linfo->stop = TRUE;
+	}
+
 }
 
 static void
@@ -221,6 +232,8 @@
 
 	linfo.stop = FALSE;
 	linfo.max_pix = 0;
+	linfo.max_h = 0;
+	linfo.max_w = 0;
 
 	g_signal_connect (loader, "size-prepared", 
 			  G_CALLBACK (at_scale_size_prepared_cb), &info);
@@ -258,6 +271,7 @@
 my_gdk_pixbuf_new_from_stream (GInputStream  *stream,
 			    GCancellable  *cancellable,
 			    guint          max_pix,
+			    guint max_w, guint max_h,
 			    GError       **error)
 {
 	GdkPixbuf *pixbuf;
@@ -271,6 +285,8 @@
 
 	linfo.stop = FALSE;
 	linfo.max_pix = max_pix;
+	linfo.max_w = max_w;
+	linfo.max_h = max_h;
 
 	pixbuf = load_from_stream (loader, stream, cancellable, &linfo, error);
 	g_object_unref (loader);

Modified: projects/haf/trunk/hildon-thumbnail/thumbs/hildon-thumbnail-obj.c
===================================================================
--- projects/haf/trunk/hildon-thumbnail/thumbs/hildon-thumbnail-obj.c	2009-06-11 07:28:12 UTC (rev 18700)
+++ projects/haf/trunk/hildon-thumbnail/thumbs/hildon-thumbnail-obj.c	2009-06-11 10:15:40 UTC (rev 18701)
@@ -59,11 +59,6 @@
 
 
 GdkPixbuf *
-my_gdk_pixbuf_new_from_stream (GInputStream  *stream,
-			    GCancellable  *cancellable,
-			       guint max_pix,
-			    GError       **error);
-GdkPixbuf *
 my_gdk_pixbuf_new_from_stream_at_scale (GInputStream  *stream,
 				     gint	    width,
 				     gint 	    height,

More information about the maemo-commits mailing list