comparison src/image-load.c @ 500:01fe7ca55c69

clear the buffer before loading of an image
author nadvornik
date Wed, 23 Apr 2008 22:38:34 +0000
parents c7a2471e5c4e
children fc9c8a3e1a8b
comparison
equal deleted inserted replaced
499:cc46a09d0805 500:01fe7ca55c69
41 if (il->pixbuf) gdk_pixbuf_unref(il->pixbuf); 41 if (il->pixbuf) gdk_pixbuf_unref(il->pixbuf);
42 il->pixbuf = pb; 42 il->pixbuf = pb;
43 if (il->pixbuf) gdk_pixbuf_ref(il->pixbuf); 43 if (il->pixbuf) gdk_pixbuf_ref(il->pixbuf);
44 } 44 }
45 45
46 static void image_loader_area_cb(GdkPixbufLoader *loader, 46 static void image_loader_area_updated_cb(GdkPixbufLoader *loader,
47 guint x, guint y, guint w, guint h, 47 guint x, guint y, guint w, guint h,
48 gpointer data) 48 gpointer data)
49 { 49 {
50 ImageLoader *il = data; 50 ImageLoader *il = data;
51 51
59 printf("critical: area_ready signal with NULL pixbuf (out of mem?)\n"); 59 printf("critical: area_ready signal with NULL pixbuf (out of mem?)\n");
60 } 60 }
61 } 61 }
62 il->func_area_ready(il, x, y, w, h, il->data_area_ready); 62 il->func_area_ready(il, x, y, w, h, il->data_area_ready);
63 } 63 }
64 }
65
66 static void image_loader_area_prepared_cb(GdkPixbufLoader *loader, gpointer data)
67 {
68 GdkPixbuf *pb;
69 guchar *pix;
70 size_t h, rs;
71
72 pb = gdk_pixbuf_loader_get_pixbuf(loader);
73
74 h = gdk_pixbuf_get_height(pb);
75 rs = gdk_pixbuf_get_rowstride(pb);
76 pix = gdk_pixbuf_get_pixels(pb);
77
78 memset(pix, 0, rs * h); /*this should be faster than pixbuf_fill */
79
64 } 80 }
65 81
66 static void image_loader_size_cb(GdkPixbufLoader *loader, 82 static void image_loader_size_cb(GdkPixbufLoader *loader,
67 gint width, gint height, gpointer data) 83 gint width, gint height, gpointer data)
68 { 84 {
293 il->bytes_total = st.st_size; 309 il->bytes_total = st.st_size;
294 } 310 }
295 311
296 il->loader = gdk_pixbuf_loader_new(); 312 il->loader = gdk_pixbuf_loader_new();
297 g_signal_connect(G_OBJECT(il->loader), "area_updated", 313 g_signal_connect(G_OBJECT(il->loader), "area_updated",
298 G_CALLBACK(image_loader_area_cb), il); 314 G_CALLBACK(image_loader_area_updated_cb), il);
299 g_signal_connect(G_OBJECT(il->loader), "size_prepared", 315 g_signal_connect(G_OBJECT(il->loader), "size_prepared",
300 G_CALLBACK(image_loader_size_cb), il); 316 G_CALLBACK(image_loader_size_cb), il);
317 g_signal_connect(G_OBJECT(il->loader), "area_prepared",
318 G_CALLBACK(image_loader_area_prepared_cb), il);
301 319
302 il->shrunk = FALSE; 320 il->shrunk = FALSE;
303 321
304 return image_loader_begin(il); 322 return image_loader_begin(il);
305 } 323 }