Add error handlers to JPEG and PNG image classes so the corresponding

libraries don't exit the app with a bad file (STR #168)


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@3105 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Michael R Sweet 2003-09-15 23:52:38 +00:00
parent aed1a91613
commit db0939a599
3 changed files with 27 additions and 4 deletions

View File

@ -1,5 +1,8 @@
CHANGES IN FLTK 1.1.5rc1
- The Fl_JPEG_Image and Fl_PNG_Image classes did not
trap errors from the corresponding image libraries
(STR #168)
- Added "--with-links" configure option to control
whether symlinks are created for the FLTK header files
(STR #164)

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_JPEG_Image.cxx,v 1.1.2.7 2003/01/30 21:42:02 easysw Exp $"
// "$Id: Fl_JPEG_Image.cxx,v 1.1.2.8 2003/09/15 23:52:37 easysw Exp $"
//
// Fl_JPEG_Image routines.
//
@ -55,6 +55,17 @@ extern "C"
}
//
// Error handler for JPEG files...
//
static void
jpeg_error_handler(j_common_ptr)
{
return;
}
//
// 'Fl_JPEG_Image::Fl_JPEG_Image()' - Load a JPEG image file.
//
@ -71,6 +82,8 @@ Fl_JPEG_Image::Fl_JPEG_Image(const char *jpeg) // I - File to load
if ((fp = fopen(jpeg, "rb")) == NULL) return;
cinfo.err = jpeg_std_error(&jerr);
jerr.error_exit = jpeg_error_handler;
jpeg_create_decompress(&cinfo);
jpeg_stdio_src(&cinfo, fp);
jpeg_read_header(&cinfo, 1);
@ -107,5 +120,5 @@ Fl_JPEG_Image::Fl_JPEG_Image(const char *jpeg) // I - File to load
}
//
// End of "$Id: Fl_JPEG_Image.cxx,v 1.1.2.7 2003/01/30 21:42:02 easysw Exp $".
// End of "$Id: Fl_JPEG_Image.cxx,v 1.1.2.8 2003/09/15 23:52:37 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_PNG_Image.cxx,v 1.1.2.9 2003/01/30 21:42:23 easysw Exp $"
// "$Id: Fl_PNG_Image.cxx,v 1.1.2.10 2003/09/15 23:52:38 easysw Exp $"
//
// Fl_PNG_Image routines.
//
@ -32,6 +32,7 @@
// Include necessary header files...
//
#include <FL/Fl.H>
#include <FL/Fl_PNG_Image.H>
#include <config.h>
#include <stdio.h>
@ -72,6 +73,12 @@ Fl_PNG_Image::Fl_PNG_Image(const char *png) // I - File to read
pp = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
info = png_create_info_struct(pp);
if (setjmp(pp->jmpbuf))
{
Fl::warning("PNG file \"%s\" contains errors!\n", png);
return;
}
// Initialize the PNG read "engine"...
png_init_io(pp, fp);
@ -132,5 +139,5 @@ Fl_PNG_Image::Fl_PNG_Image(const char *png) // I - File to read
//
// End of "$Id: Fl_PNG_Image.cxx,v 1.1.2.9 2003/01/30 21:42:23 easysw Exp $".
// End of "$Id: Fl_PNG_Image.cxx,v 1.1.2.10 2003/09/15 23:52:38 easysw Exp $".
//