FLTK logo

[branch-1.3] eda03f0 - Backport fix for issue #185 "Shared Image reload() loses initial dimensions" from branch 1.4

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[branch-1.3] eda03f0 - Backport fix for issue #185 "Shared Image reload() loses initial dimensions" from branch 1.4 "ManoloFLTK" Feb 17, 2021  
 
commit eda03f0f8888d2cf96fae2ecc5da4a17117148e3
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Wed Feb 17 09:30:08 2021 +0100
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Wed Feb 17 09:30:26 2021 +0100

    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 src/Fl_Shared_Image.cxx src/Fl_Shared_Image.cxx
index 3e099ce..9b0004b 100644
--- src/Fl_Shared_Image.cxx
+++ 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
   }
 }
 
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.