On 02/05/12 11:21, mattes wrote:
> The code below works fine in linux. The image displays.
> Using the same code under windows does not show the
> image. All i get is the window with its gray background.
> Executing the code does not produce any error message.

        Are you certain the "current working directory" (cwd)
        is set to the directory where the foo.jpg resides?

        It might not be if you just double-click on it
        (eg. desktop or folder browser).

        Try adding some error checking to the app
        to show if the file can be accessed, and if not,
        showing what the cwd is. e.g.

#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Shared_Image.H>
#include <FL/Fl_JPEG_Image.H>
#include <FL/Fl_Box.H>
#include <FL/fl_draw.H>
#include <FL/fl_ask.H>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#ifdef WIN32
#include <direct.h>
#define getcwd _getcwd
#else
#include <unistd.h>
#endif

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);
    }
}
int main() {
    fl_register_images();
    CheckIfExists("foo.jpg");
    Fl_Window     win(720,486);
    Fl_Box        box(10,10,720-20,486-20);
    Fl_JPEG_Image jpg("foo.jpg");
    box.image(jpg);
    win.show();
    return(Fl::run());
}
_______________________________________________
fltk mailing list
fltk@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to