changeset 500:01fe7ca55c69

clear the buffer before loading of an image
author nadvornik
date Wed, 23 Apr 2008 22:38:34 +0000
parents cc46a09d0805
children 1bac19d5a663
files src/image-load.c
diffstat 1 files changed, 20 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/image-load.c	Wed Apr 23 22:33:18 2008 +0000
+++ b/src/image-load.c	Wed Apr 23 22:38:34 2008 +0000
@@ -43,7 +43,7 @@
 	if (il->pixbuf) gdk_pixbuf_ref(il->pixbuf);
 }
 
-static void image_loader_area_cb(GdkPixbufLoader *loader,
+static void image_loader_area_updated_cb(GdkPixbufLoader *loader,
 				 guint x, guint y, guint w, guint h,
 				 gpointer data)
 {
@@ -63,6 +63,22 @@
 		}
 }
 
+static void image_loader_area_prepared_cb(GdkPixbufLoader *loader, gpointer data)
+{
+	GdkPixbuf *pb;
+	guchar *pix;
+	size_t h, rs;
+
+	pb = gdk_pixbuf_loader_get_pixbuf(loader);
+	
+	h = gdk_pixbuf_get_height(pb);
+	rs = gdk_pixbuf_get_rowstride(pb);
+	pix = gdk_pixbuf_get_pixels(pb);
+	
+	memset(pix, 0, rs * h); /*this should be faster than pixbuf_fill */
+
+}
+
 static void image_loader_size_cb(GdkPixbufLoader *loader,
 				 gint width, gint height, gpointer data)
 {
@@ -295,9 +311,11 @@
 
 	il->loader = gdk_pixbuf_loader_new();
 	g_signal_connect(G_OBJECT(il->loader), "area_updated",
-			 G_CALLBACK(image_loader_area_cb), il);
+			 G_CALLBACK(image_loader_area_updated_cb), il);
 	g_signal_connect(G_OBJECT(il->loader), "size_prepared",
 			 G_CALLBACK(image_loader_size_cb), il);
+	g_signal_connect(G_OBJECT(il->loader), "area_prepared",
+			 G_CALLBACK(image_loader_area_prepared_cb), il);
 
 	il->shrunk = FALSE;