diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2015-05-23 23:42:26 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2015-05-23 23:42:26 +0000 |
| commit | 0539009c671a2ffc2478a50a11f48769c5c54b27 (patch) | |
| tree | 94d297d32a43d7b71a2740c053de0518df7f23d5 /src/Fl_JPEG_Image.cxx | |
| parent | 03f69c0dd5244c50e430b430ee3a2e952b5a00fe (diff) | |
STR #2873: new function Fl_Image::fail() that returns 0, ERR_NO_IMAGE, ERR_FORMAT, or ERR_FILE_ACCESS to make life easier when loading images.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10732 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_JPEG_Image.cxx')
| -rw-r--r-- | src/Fl_JPEG_Image.cxx | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/Fl_JPEG_Image.cxx b/src/Fl_JPEG_Image.cxx index 6cebe88e9..cd3e4a462 100644 --- a/src/Fl_JPEG_Image.cxx +++ b/src/Fl_JPEG_Image.cxx @@ -111,7 +111,10 @@ Fl_JPEG_Image::Fl_JPEG_Image(const char *filename) // I - File to load array = (uchar *)0; // Open the image file... - if ((fp = fl_fopen(filename, "rb")) == NULL) return; + if ((fp = fl_fopen(filename, "rb")) == NULL) { + ld(ERR_FILE_ACCESS); + return; + } // Setup the decompressor info and read the header... dinfo.err = jpeg_std_error((jpeg_error_mgr *)&jerr); @@ -150,6 +153,7 @@ Fl_JPEG_Image::Fl_JPEG_Image(const char *filename) // I - File to load free(max_destroy_decompress_err); free(max_finish_decompress_err); + ld(ERR_FORMAT); return; } @@ -275,7 +279,10 @@ static void jpeg_mem_src(j_decompress_ptr cinfo, const unsigned char *data) The inherited destructor frees all memory and server resources that are used by the image. - There is no error function in this class. If the image has loaded correctly, + Use Fl_Image::fail() to check if Fl_BMP_Image failed to load. fail() returns + ERR_FILE_ACCESS if the file could not bo opened or read, ERR_FORMAT if the + JPEG format could not be decoded, and ERR_NO_IMAGE if the image could not + be loaded for another reason. If the image has loaded correctly, w(), h(), and d() should return values greater zero. \param name A unique name or NULL |
