Questions about Fl_Shared_Image and scaling

30 views
Skip to first unread message

Eric Sokolowsky

unread,
May 30, 2025, 11:00:55 AM5/30/25
to fltk.general
Hello,

I could use some guidance on how to properly use scaled images. I'm using FLTK 1.4.3 on Linux (Rocky 8 specifically).

I'm loading a bunch of images (using Fl_Shared_Image::get()) and scaling them to be a small thumbnail size (using Fl_Shared_Image::scale()). When the user selects one of the thumbnails I want to show the full-size image in another pane. When I use Fl_Shared_Image::get() on the same filename, I'm only getting the small scaled version of the image. How do I get the full-size image to show in that other pane? I also looked at each of the scaled images and they still have the original() flag set, which is not what I expected.

Thanks,
Eric

lifeatt...@gmail.com

unread,
May 30, 2025, 6:24:17 PM5/30/25
to fltk.general
Fl_Image::scale() is counter-intuitive (at least to me). It does not modify the loaded image, but "merely" modifies the internal height/width values! Subsequent uses of the image (e.g. get()) as you found, refer to those internal values but don't modify the original image. Thus, original() is correctly true.  [Note I said Fl_Image::scale(), not Fl_Shared_Image::scale() as there is no overload].

You don't want to invoke scale() at all. For each pane you are showing the image, invoke Fl_Shared_Image::draw() with the target dimensions. I.e. when showing the thumbnail, call draw(x,y,thumbw,thumbh), and when showing the full size image, call draw(x,y). In each case, the image should be drawn to the desired size, yet the original image is still unmodified.

Hope that helps,
Kevin
Reply all
Reply to author
Forward
0 new messages