From eda03f0f8888d2cf96fae2ecc5da4a17117148e3 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Wed, 17 Feb 2021 09:30:08 +0100 Subject: [PATCH] Backport fix for issue #185 "Shared Image reload() loses initial dimensions" from branch 1.4 --- src/Fl_Shared_Image.cxx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Fl_Shared_Image.cxx b/src/Fl_Shared_Image.cxx index 3e099cecf..9b0004b5c 100644 --- a/src/Fl_Shared_Image.cxx +++ b/src/Fl_Shared_Image.cxx @@ -291,7 +291,11 @@ void Fl_Shared_Image::reload() { if (alloc_image_) delete image_; alloc_image_ = 1; - +#if FLTK_ABI_VERSION >= 10304 + image_ = img; + int W = w(); + int H = h(); +#else if ((img->w() != w() && w()) || (img->h() != h() && h())) { // Make sure the reloaded image is the same size as the existing one. Fl_Image *temp = img->copy(w(), h()); @@ -300,8 +304,13 @@ void Fl_Shared_Image::reload() { } else { image_ = img; } - +#endif update(); +#if FLTK_ABI_VERSION >= 10304 + // Make sure the reloaded image gets the same drawing size as the existing one. + if (W) + scale(W, H, 0, 1); +#endif } }