Error displaying an image using GUI

38 views
Skip to first unread message

henn...@sgasd.org

unread,
Mar 20, 2012, 11:57:42 AM3/20/12
to PPP-public
No matter what image I use I get an error message in the window where
the image is supposed to load that says cannot open "c.jpg" which is
the name of the image file. I have tried many different files
including the rita image from the sourse files on the PPP site.

Any Ideas?

henn...@sgasd.org

unread,
Mar 20, 2012, 12:01:58 PM3/20/12
to PPP-public

This is while trying to write something similar to 13.17

Here is the line pertaining to the images:
suit.push_back(new Image(Point(i*100+i*5+30,120),cards[i].file()));

I also have:
win.attach(suit[i]);

suit is a vector_ref:
Vector_ref<Image> suit;

cortical_iv

unread,
Jun 13, 2018, 8:53:39 PM6/13/18
to PPP-public
I had this problem and had to put the full path to the image to get it to work:

  Image image1{Point{100,50}, "/home/user/stroustrup/chapter12/image_tester/simple_image.jpg"};

It would be really cool if the book addressed issues of path (relative/absolute or what?) in fltk. But for now I'm just using the full dang filepath because that's what works! In the book it just has "image.jpg" or whatever but that was giving me the same error as you no matter what I did.

cortical_iv

unread,
Jun 13, 2018, 8:55:04 PM6/13/18
to PPP-public
Put the image in the same directory as the executable.
Reply all
Reply to author
Forward
0 new messages