GdkPixbuf: png loader doing too much work?



Hi,

Is there any reason why the png loader in gdk-pixbup loads the image
into temporary row buffers, and then copies them to the art_pixbuf
pixel buffer?  In other words is there any reason why the patch below
shouldn't be applied?

On a side note: what are the plans for progressive loading?

regards,
Kristian

--- io-png.c	Wed Oct 20 22:57:22 1999
+++ io-png-new.c	Thu Oct 21 18:33:50 1999
@@ -127,43 +127,16 @@
 		return NULL;
 	}
 
-	/* Icky code, but it has to be done... */
+	temp = pixels;
 	for (i = 0; i < h; i++) {
-		if ((rows[i] = malloc (w * bpp)) == NULL) {
-			int n;
-
-			for (n = 0; n < i; n++)
-				free (rows[i]);
-
-			free (rows);
-			free (pixels);
-			png_destroy_read_struct (&png_ptr, &info_ptr, &end_info);
-			return NULL;
-		}
+	        rows[i] = temp;
+		temp += w * bpp;
 	}
 
 	/* And we FINALLY get here... */
 	png_read_image (png_ptr, rows);
 	png_destroy_read_struct (&png_ptr, &info_ptr, &end_info);
 
-	/* Now stuff the bytes into pixels & free rows[y] */
-
-	temp = pixels;
-
-	for (y = 0; y < h; y++) {
-		rowdata = rows[y];
-		for (x = 0; x < w; x++) {
-			temp[0] = rowdata[(x * bpp)];
-			temp[1] = rowdata[(x * bpp) + 1];
-			temp[2] = rowdata[(x * bpp) + 2];
-
-			if (bpp == 4)
-				temp[3] = rowdata[(x * bpp) + 3];
-
-			temp += bpp;
-		}
-		free (rows[y]);
-	}
 	free (rows);
 
 	if (ctype & PNG_COLOR_MASK_ALPHA)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]