On 09/19/12 10:00, Doug Parks wrote:
>>   Fl_BMP_Image jpg("C:/Users/Marick/My Pictures/image.bmp");
>>
> After looking at my code again for the 1000th time I just realized I was 
> using an invalid file path.  There is no "My Pictures" only a "Pictures" 
> folder.
> Thank you for taking the time to help Ian.

        I wonder if we could make error checking more obvious for the default
        behavior in FLTK for this type of thing.

        I can think of three possible ways to help:

                o A global Fl::option() to control how image errors are shown
                o An error_callback() to be called when the image can't be 
loaded
                o Adjust the docs + examples to include error checking

        For a 'flags' approach:

                Fl::option(FL_OPTION_IMAGE_ERROR_MESSAGE, bitflags)

        ..where 'bitflags' might be:

                0 -- error messages off (current behavior)
                1 -- error messages shown in an fl_alert()
                2 -- error messages shown on stderr
                4 -- error messages shown in the image
                8 -- error messages shown as a tooltip
                16 -- error causes an 'X' image to be shown

        ..and having multiple bits set would do all the above.

        If we did that, what's the best default? '0' would be the current
        behavior, but perhaps a cop out. It'd be nice if the default could
        be to show an error message. But a bad side to that is existing apps
        that run fine when images can't be found would start popping up
        unwanted errors with the new default, forcing apps to add code to 
disable.
        (Perhaps this would be good though, as it would expose errors in code)

        Or, an error_callback() that is called when an image error occurs,
        with the default callback being one or more of the above behaviors.

        At very least, some adjustments to the docs/examples/cheat pages to show
        how to do error checking when an image can't be loaded, so that simple
        copy/pastes include error checking that would have helped the OP, eg:

                if ( img->d() == 0 )
                    { fl_alert("%s: %s", img->filename(), strerror(errno)); }

        ..and we should maybe add an img->filename() method to make it easy
        to get the filename that was used, since the user might not have made
        it a variable..

        Suggs?
_______________________________________________
fltk mailing list
fltk@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to