summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FL/Fl_Image.H7
-rw-r--r--src/Fl_Image.cxx26
2 files changed, 26 insertions, 7 deletions
diff --git a/FL/Fl_Image.H b/FL/Fl_Image.H
index ea408ebcd..818e656ee 100644
--- a/FL/Fl_Image.H
+++ b/FL/Fl_Image.H
@@ -129,13 +129,6 @@ public:
Use the count() method to find the size of the data array.
*/
const char * const *data() const {return data_;}
- /**
- Returns a value that is not 0 if there is currently no image
- available.
- \return ERR_NO_IMAGE if no image was found
- \return ERR_FILE_ACCESS if there was a file access related error (errno should be set)
- \return ERR_FORMAT if image decoding failed.
- */
int fail();
Fl_Image(int W, int H, int D);
virtual ~Fl_Image();
diff --git a/src/Fl_Image.cxx b/src/Fl_Image.cxx
index 8afd232dc..a5d1bc750 100644
--- a/src/Fl_Image.cxx
+++ b/src/Fl_Image.cxx
@@ -140,6 +140,32 @@ void Fl_Image::label(Fl_Menu_Item* m) {
m->label(_FL_IMAGE_LABEL, (const char*)this);
}
+/**
+ Returns a value that is not 0 if there is currently no image
+ available.
+
+ Example use:
+ \code
+ [..]
+ Fl_Box box(X,Y,W,H);
+ Fl_JPEG_Image jpg("/tmp/foo.jpg");
+ switch ( jpg.fail() ) {
+ case Fl_Image::ERR_NO_IMAGE:
+ case Fl_Image::ERR_FILE_ACCESS:
+ fl_alert("/tmp/foo.jpg: %s", strerror(errno)); // shows actual os error to user
+ exit(1);
+ case Fl_Image::ERR_FORMAT:
+ fl_alert("/tmp/foo.jpg: couldn't decode image");
+ exit(1);
+ }
+ box.image(jpg);
+ [..]
+ \endcode
+
+ \return ERR_NO_IMAGE if no image was found
+ \return ERR_FILE_ACCESS if there was a file access related error (errno should be set)
+ \return ERR_FORMAT if image decoding failed.
+ */
int Fl_Image::fail()
{
// if no image exists, ld_ may contain a simple error code