* Michael Fulbright <drmike@redhat.com>
*
* This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
+ * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
+ * Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Library General Public
+ * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
#include <string.h>
#include <setjmp.h>
#include <jpeglib.h>
-#include "gdk-pixbuf.h"
+#include "gdk-pixbuf-private.h"
#include "gdk-pixbuf-io.h"
+#ifndef HAVE_SIGSETJMP
+#define sigjmp_buf jmp_buf
+#define sigsetjmp(jb, x) setjmp(jb)
+#define siglongjmp longjmp
+#endif
\f
/* we are a "source manager" as far as libjpeg is concerned */
errmgr = (struct error_handler_data *) cinfo->err;
cinfo->err->output_message (cinfo);
siglongjmp (errmgr->setjmp_buffer, 1);
- return;
+
+ /* incase the jmp buf isn't initted? */
+ exit(1);
}
-/* Destroy notification function for the libart pixbuf */
+/* Destroy notification function for the pixbuf */
static void
-free_buffer (gpointer user_data, gpointer data)
+free_buffer (guchar *pixels, gpointer data)
{
- free (data);
+ free (pixels);
}
jpeg_finish_decompress (&cinfo);
jpeg_destroy_decompress (&cinfo);
- return gdk_pixbuf_new_from_data (pixels, ART_PIX_RGB, FALSE,
+ return gdk_pixbuf_new_from_data (pixels, GDK_COLORSPACE_RGB, FALSE, 8,
w, h, w * 3,
free_buffer, NULL);
}
src = (my_src_ptr) context->cinfo.src;
context->cinfo.err = jpeg_std_error (&context->jerr.pub);
+ context->jerr.pub.error_exit = fatal_error_handler;
src = (my_src_ptr) context->cinfo.src;
src->pub.init_source = init_source;
if (context->pixbuf)
gdk_pixbuf_unref (context->pixbuf);
- jpeg_finish_decompress(&context->cinfo);
- jpeg_destroy_decompress(&context->cinfo);
+ /* if we have an error? */
+ if (sigsetjmp (context->jerr.setjmp_buffer, 1)) {
+ jpeg_destroy_decompress (&context->cinfo);
+ } else {
+ jpeg_finish_decompress(&context->cinfo);
+ jpeg_destroy_decompress(&context->cinfo);
+ }
if (context->cinfo.src) {
my_src_ptr src = (my_src_ptr) context->cinfo.src;
* have a grasp of what the flow needs to be!
*/
+ /* check for fatal error */
+ if (sigsetjmp (context->jerr.setjmp_buffer, 1)) {
+ return FALSE;
+ }
/* skip over data if requested, handle unsigned int sizes cleanly */
/* only can happen if we've already called jpeg_get_header once */
return FALSE;
}
#endif
- context->pixbuf = gdk_pixbuf_new(ART_PIX_RGB,
- /*have_alpha*/ FALSE,
+ context->pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
+ FALSE,
8,
cinfo->image_width,
cinfo->image_height);
}
/* Use pixbuf buffer to store decompressed data */
- context->dptr = context->pixbuf->art_pixbuf->pixels;
+ context->dptr = context->pixbuf->pixels;
/* Notify the client that we are ready to go */
(* context->prepared_func) (context->pixbuf,
rowptr = context->dptr;
for (i=0; i < cinfo->rec_outbuf_height; i++) {
*lptr++ = rowptr;
- rowptr += context->pixbuf->art_pixbuf->rowstride;
+ rowptr += context->pixbuf->rowstride;
}
nlines = jpeg_read_scanlines (cinfo, lines,
if (cinfo->output_components == 1)
explode_gray_into_buf (cinfo, lines);
- context->dptr += nlines * context->pixbuf->art_pixbuf->rowstride;
+ context->dptr += nlines * context->pixbuf->rowstride;
/* send updated signal */
(* context->updated_func) (context->pixbuf,