diff -urp gtk+-2.6.7.orig/gdk-pixbuf/gdk-pixbuf-loader.c gtk+-2.6.7.scale2/gdk-pixbuf/gdk-pixbuf-loader.c
--- gtk+-2.6.7.orig/gdk-pixbuf/gdk-pixbuf-loader.c	Mon Mar 14 21:20:39 2005
+++ gtk+-2.6.7.scale2/gdk-pixbuf/gdk-pixbuf-loader.c	Mon May 30 23:04:43 2005
@@ -754,7 +754,7 @@ gdk_pixbuf_loader_close (GdkPixbufLoader
         if (priv->needs_scale) 
                 {
                         GdkPixbuf *tmp, *pixbuf;
-                        
+
                         tmp = gdk_pixbuf_animation_get_static_image (priv->animation);
                         g_object_ref (tmp);
                         pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, tmp->has_alpha, 8, priv->width, priv->height);
@@ -762,6 +762,8 @@ gdk_pixbuf_loader_close (GdkPixbufLoader
                         priv->animation = gdk_pixbuf_non_anim_new (pixbuf);
                         g_object_unref (pixbuf);
                         g_signal_emit (loader, pixbuf_loader_signals[AREA_PREPARED], 0);
+			/* 10000x10000 downscaled to 9000x9000... almost x2 memory use! */
+			/* We need in-place resampler - todo */
                         gdk_pixbuf_scale (tmp, pixbuf, 0, 0, priv->width, priv->height, 0, 0,
                                           (double) priv->width / tmp->width,
                                           (double) priv->height / tmp->height,
diff -urp gtk+-2.6.7.orig/gdk-pixbuf/io-jpeg.c gtk+-2.6.7.scale2/gdk-pixbuf/io-jpeg.c
--- gtk+-2.6.7.orig/gdk-pixbuf/io-jpeg.c	Fri Nov 12 07:34:31 2004
+++ gtk+-2.6.7.scale2/gdk-pixbuf/io-jpeg.c	Mon May 30 23:10:43 2005
@@ -519,7 +519,7 @@ gdk_pixbuf__jpeg_image_stop_load (gpoint
         /* FIXME this thing needs to report errors if
          * we have unused image data
          */
-        
+
 	if (context->pixbuf)
 		g_object_unref (context->pixbuf);
 	
@@ -691,7 +691,12 @@ gdk_pixbuf__jpeg_image_load_increment (g
 			int rc;			
 			
 			/* start decompression */
-			cinfo->buffered_image = TRUE;
+
+/* bad, bad, BAD!!! Memory usage in libjpeg will skyrocket
+   (upto 2 x uncompressed_image_size!). Read libjpeg.doc,
+   "Memory usage" section in libjpeg source tree */
+			/*cinfo->buffered_image = TRUE; */
+			cinfo->buffered_image = FALSE;
 			rc = jpeg_start_decompress (cinfo);
 			cinfo->do_fancy_upsampling = FALSE;
 			cinfo->do_block_smoothing = FALSE;
@@ -706,7 +711,7 @@ gdk_pixbuf__jpeg_image_load_increment (g
 			guchar **lptr;
 			guchar *rowptr;
 			gint   nlines, i;
-
+#if 0	/* buffered_image = TRUE */
 			/* keep going until we've done all passes */
 			while (!jpeg_input_complete (cinfo)) {
 				if (!context->in_output) {
@@ -774,6 +779,60 @@ gdk_pixbuf__jpeg_image_load_increment (g
 				return TRUE;
 			else
 				continue;
+#else	/* buffered_image = FALSE */
+/* This code is a quick hack and may well be buggy */
+			/* keep going until we've done all scanlines */
+			while (cinfo->output_scanline < cinfo->output_height) {
+				lptr = lines;
+				rowptr = context->dptr;
+				for (i=0; i < cinfo->rec_outbuf_height; i++) {
+					*lptr++ = rowptr;
+					rowptr += context->pixbuf->rowstride;
+				}
+				
+				nlines = jpeg_read_scanlines (cinfo, lines,
+							      cinfo->rec_outbuf_height);
+				if (nlines == 0)
+					break;
+
+				switch (cinfo->out_color_space) {
+				    case JCS_GRAYSCALE:
+					    explode_gray_into_buf (cinfo, lines);
+					    break;
+				    case JCS_RGB:
+					    /* do nothing */
+					    break;
+				    case JCS_CMYK:
+					    convert_cmyk_to_rgb (cinfo, lines);
+					    break;
+				    default:
+					    if (error && *error == NULL) {
+						    g_set_error (error,
+								 GDK_PIXBUF_ERROR,
+								 GDK_PIXBUF_ERROR_UNKNOWN_TYPE,
+								 _("Unsupported JPEG color space (%s)"),
+								 colorspace_name (cinfo->out_color_space)); 
+					    }
+					    
+					    return FALSE;
+				}
+
+				context->dptr += nlines * context->pixbuf->rowstride;
+				
+			        /* send updated signal */
+				(* context->updated_func) (context->pixbuf,
+							   0, 
+							   cinfo->output_scanline-1,
+							   cinfo->image_width, 
+							   nlines,
+							   context->user_data);
+			}
+			if (jpeg_input_complete(cinfo)) /* undocumented for buffered_image = FALSE... */
+				/* did entire image */
+				return TRUE;
+			else
+				continue;
+#endif
 		}
 	}
 
