From 5ade8fcb09ad2f30d0ee84228f062bdfc8ecdc50 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Fri, 12 Feb 2021 07:32:35 +0100 Subject: Fix for issue #185 "Shared Image reload() loses initial dimensions" --- src/Fl_Shared_Image.cxx | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/Fl_Shared_Image.cxx b/src/Fl_Shared_Image.cxx index e0bb524ad..832d8a3a0 100644 --- a/src/Fl_Shared_Image.cxx +++ b/src/Fl_Shared_Image.cxx @@ -280,17 +280,13 @@ void Fl_Shared_Image::reload() { if (alloc_image_) delete image_; alloc_image_ = 1; - - if ((img->w() != data_w() && data_w()) || (img->h() != data_h() && data_h())) { - // Make sure the reloaded image is the same size as the existing one. - Fl_Image *temp = img->copy(data_w(), data_h()); - delete img; - image_ = temp; - } else { - image_ = img; - } - + image_ = img; + int W = w(); + int H = h(); update(); + // Make sure the reloaded image gets the same drawing size as the existing one. + if (W) + scale(W, H, 0, 1); } } -- cgit v1.2.3