Slick Dealer wrote:
> All,
> I am having problems with my simple code to display an image on a window. The
> code compiles fine but I don't see the image !
> I'll appreciate your inputs on making it work & display a jpg image :)
>
> #include <fltk/Window.h>
> #include <fltk/Image.h>
> #include <fltk/run.h>
#include <fltk/SharedImage.h>
>
> using namespace fltk;
> int main() {
register_images();
> Window win(900,900); // make a window
> win.begin();
> Widget box(10,10,900-20,900-20,"yahoo"); // widget contains image
replace this line:
> Image *test = new Image("junk.jpg");
with:
Image *test = SharedImage::get("junk.jpg");
> box.image(test); // attach jpg image to box
> win.end();
> win.show();
> return run();
> }
Notes: Are you new to FLTK? If yes, you shouldn't use FLTK 2, unless there
are important reasons to do so. FLTK 2 is currently not maintained, and
thus you can't expect to get much help here. For more info about the
versions of FLTK see:
http://www.fltk.org/articles.php?L825
That said, if you follow the instructions above, you will be able
to show an image. Maybe that's not the most elegant way, but it works.
You will need to link with the image libs, though. I compiled the
program with:
fltk2-config --use-images --compile image.cxx
Note 2: I'm not a FLTK 2 user, and I don't know if there are other
usable image constructors, but SharedImage::get() works...
Albrecht
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk