summaryrefslogtreecommitdiff
path: root/src/Fl_GIF_Image.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2015-05-23 23:42:26 +0000
committerMatthias Melcher <fltk@matthiasm.com>2015-05-23 23:42:26 +0000
commit0539009c671a2ffc2478a50a11f48769c5c54b27 (patch)
tree94d297d32a43d7b71a2740c053de0518df7f23d5 /src/Fl_GIF_Image.cxx
parent03f69c0dd5244c50e430b430ee3a2e952b5a00fe (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_GIF_Image.cxx')
-rw-r--r--src/Fl_GIF_Image.cxx18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/Fl_GIF_Image.cxx b/src/Fl_GIF_Image.cxx
index 601da9f12..b541979b4 100644
--- a/src/Fl_GIF_Image.cxx
+++ b/src/Fl_GIF_Image.cxx
@@ -71,27 +71,36 @@ typedef unsigned char uchar;
#define GETSHORT(var) var = NEXTBYTE; var += NEXTBYTE << 8
/**
- The constructor loads the named GIF image.
- <P>The inherited destructor free all memory and server resources that are used by
- the image.
-*/
+ The constructor loads the named GIF image.
+
+ The inherited destructor free all memory and server resources that are used
+ by the image.
+
+ 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
+ GIF format could not be decoded, and ERR_NO_IMAGE if the image could not
+ be loaded for another reason.
+ */
Fl_GIF_Image::Fl_GIF_Image(const char *infname) : Fl_Pixmap((char *const*)0) {
FILE *GifFile; // File to read
char **new_data; // Data array
if ((GifFile = fl_fopen(infname, "rb")) == NULL) {
Fl::error("Fl_GIF_Image: Unable to open %s!", infname);
+ ld(ERR_FILE_ACCESS);
return;
}
{char b[6];
if (fread(b,1,6,GifFile)<6) {
fclose(GifFile);
+ ld(ERR_FILE_ACCESS);
return; /* quit on eof */
}
if (b[0]!='G' || b[1]!='I' || b[2] != 'F') {
fclose(GifFile);
Fl::error("Fl_GIF_Image: %s is not a GIF file.\n", infname);
+ ld(ERR_FORMAT);
return;
}
if (b[3]!='8' || b[4]>'9' || b[5]!= 'a')
@@ -135,6 +144,7 @@ Fl_GIF_Image::Fl_GIF_Image(const char *infname) : Fl_Pixmap((char *const*)0) {
if (i<0) {
fclose(GifFile);
Fl::error("Fl_GIF_Image: %s - unexpected EOF",infname);
+ w(0); h(0); d(0); ld(ERR_FORMAT);
return;
}
int blocklen;