Hmm, I usually use
Fl_JPEG_Image* o=new Fl_JPEG_Image(file);
if (o && o->w() && o->h())
{/*loaded successfully*/}
else {/*some error occured*/}
It never failed so far on all the platforms I tested (Win/Linux/Mac).
So I don't really see why to add anything to the library, since it works
just fine like that, but ...
maybe having an global fl_image_load_error flag would be enough, if at
all? Something similar to errno but only for FLTK images? Seems simpler
to implement than Fl::option, or error_callbacks... just a thought, though.
Cheers,
Herman
> Our docs for the Fl_JPEG_Image constructor says:
>
> There is no error function in this class.
> If the image has loaded correctly,
> w(), h(), and d() should return values greater zero.<--
>
> ..which seems to imply the following pattern should work:
>
> const char *filename = "/var/tmp/foo.jpg"; // the file to load
> Fl_JPEG_Image jpg(filename); // load jpeg image
> into ram
> if ( jpg.d() == 0 ) { // optional error
> checking
> fl_alert("%s: %s", filename, strerror(errno)); // post dialog
> showing problem
> }
>
> However, it seems we have a bug: I just did a test with 1.3.x,
> jpg.d() returned 3 even if the file doesn't exist, which seems to
> break contract with our docs.
>
> Changing the test to check jpg.w() does work though.
> I've made an STR (#2873) for this.
>
> However, I think even the above can give a misleading error message
> if e.g. the file exists but is corrupt in some way, causing the above
> to give a random errno message, instead of indicating the file is
> corrupt.
>
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk