diff options
author | Michael Fulbright <drmike@redhat.com> | 1999-11-09 17:24:15 +0000 |
---|---|---|
committer | Michael Fulbright <drmike@src.gnome.org> | 1999-11-09 17:24:15 +0000 |
commit | 5de53804a13731f7928b95ae2bf96976e3078a40 (patch) | |
tree | f1682706f37bed41debe227f40f2daf60a2021ed /gdk-pixbuf/io-jpeg.c | |
parent | 665096fcdff23b4333ce5d2d7171200d3838d73e (diff) | |
download | gtk+-5de53804a13731f7928b95ae2bf96976e3078a40.tar.gz |
Figured out problem with loading Progressive JPEG's progressively (say
1999-11-09 Michael Fulbright <drmike@redhat.com>
* src/io-jpeg.c (image_load_increment): Figured out problem with
loading Progressive JPEG's progressively (say that 10 times fast).
Currently for Progressive JPEG's the entire image is loaded before
it is displayed. libjpeg supports a fancier mechanism which I may
implement later.
With these changes all JPEG formats appear to load properly for me.
Diffstat (limited to 'gdk-pixbuf/io-jpeg.c')
-rw-r--r-- | gdk-pixbuf/io-jpeg.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/gdk-pixbuf/io-jpeg.c b/gdk-pixbuf/io-jpeg.c index 119e9e5173..208ec01923 100644 --- a/gdk-pixbuf/io-jpeg.c +++ b/gdk-pixbuf/io-jpeg.c @@ -354,6 +354,7 @@ image_load_increment (gpointer data, guchar *buf, guint size) guint num_left, num_copy; guint last_bytes_left; guint spinguard; + gboolean first; guchar *bufhd; g_return_val_if_fail (context != NULL, FALSE); @@ -384,10 +385,13 @@ image_load_increment (gpointer data, guchar *buf, guint size) bufhd = buf; } + if (num_left == 0) + return TRUE; last_bytes_left = 0; spinguard = 0; - while (src->pub.bytes_in_buffer != 0 || num_left != 0) { + first = TRUE; + while (TRUE) { /* handle any data from caller we haven't processed yet */ if (num_left > 0) { @@ -410,9 +414,10 @@ image_load_increment (gpointer data, guchar *buf, guint size) num_left -= num_copy; } else { /* did anything change from last pass, if not return */ - if (last_bytes_left == 0) + if (first) { last_bytes_left = src->pub.bytes_in_buffer; - else if (src->pub.bytes_in_buffer == last_bytes_left) + first = FALSE; + } else if (src->pub.bytes_in_buffer == last_bytes_left) spinguard++; else last_bytes_left = src->pub.bytes_in_buffer; @@ -434,12 +439,13 @@ image_load_increment (gpointer data, guchar *buf, guint size) context->got_header = TRUE; +#if 0 if (jpeg_has_multiple_scans (cinfo)) { g_print ("io-jpeg.c: Does not currently " "support progressive jpeg files.\n"); return FALSE; } - +#endif context->pixbuf = gdk_pixbuf_new(ART_PIX_RGB, /*have_alpha*/ FALSE, 8, @@ -471,6 +477,7 @@ image_load_increment (gpointer data, guchar *buf, guint size) context->did_prescan = TRUE; } else { + /* we're decompressing so feed jpeg lib scanlines */ guchar *lines[4]; guchar **lptr; @@ -488,11 +495,6 @@ image_load_increment (gpointer data, guchar *buf, guint size) rowptr += context->pixbuf->art_pixbuf->rowstride;; } -#ifdef IO_JPEG_DEBUG_GREY - for (p=lines[0],i=0; i< context->pixbuf->art_pixbuf->rowstride;i++, p++) - *p = 0; - -#endif nlines = jpeg_read_scanlines (cinfo, lines, cinfo->rec_outbuf_height); if (nlines == 0) |