On 02/08/12 19:28, leowang wrote:
>     window->image(Fl_Shared_Image::get("test.bmp"));
> 
> But when I run the program in my arm board, it only display white but not the 
> test.bmp. I can sure the test.bmp is in the correct position.
> Can anyone tell my why? Thanks.

        I would add some error checking to see if test.bmp is
        accessible at runtime.

        Since you're giving it a relative path, it might not
        be able to find the file, or perhaps can't read it
        for some other reason, such as the BMP's internal
        format. (Perhaps try a jpeg or png.)

        To add error checking, try adding this function
        to your app:

void CheckIfExists(const char *filename) {
    FILE *fp = fopen(filename, "r");
    if ( !fp ) {
        char cwd[4096];
        getcwd(cwd, sizeof(cwd));
        if ( filename[0] != '\\' && filename[0] != '/' ) {
            fl_alert("Cannot not open '%s' in directory %s: %s",
                     filename, cwd, strerror(errno));
        } else {
            fl_alert("Cannot not open '%s': %s\n", filename, strerror(errno));
        }
        exit(1);
    }
}

        ..then calling it here in your program:

    [..]
    Fl_Window *window = new Fl_Window(0, 0, 1280, 800);
    CheckIfExists("test.bmp");           // <-- ADD THIS LINE
    window->image(Fl_Shared_Image::get("test.bmp"));
    [..]

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

Reply via email to