Search code examples
c++jpegfilepathfltk

open image with FLTK on windows


I'm having problem: I was trying to add image to my _fl_group_ but was not able to do so.

I was trying to identify where the problem occurs and according to specification on fltk's webpage, if image is opened with fl_JPEG_image(const char* path) constructor correctly, calling im->w() should return > 0 but it does not.

I don't know if I'm entering path correctly (in proper way)? I'm on win and the path to file is "e:\\zaloha\\Pictures\\my\\DSC_0242.jpg" and that is the way I typed it but after opening width is still 0 here is my code:

Fl_JPEG_Image* im = new Fl_JPEG_Image("e:\\zaloha\\Pictures\\my\\DSC_0242.jpg");
double w = im->w();
double h = im->h();
double d = im->d();
images.push_back(im);
Fl_Box* box = new Fl_Box(10,10,600,400);
box->image(im);
Pic_GR->add(box);

so as a result I have no image draw.


Solution

  • Actually the solution is simple:

    Despite using Windows you have to enter Unix style path, so instead of backward "\\" simply use "/" so the path should look like this: "e:/zaloha/Pictures/my/DSC_0242.jpg"