diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2021-02-12 07:32:35 +0100 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2021-02-12 07:32:49 +0100 |
| commit | 5ade8fcb09ad2f30d0ee84228f062bdfc8ecdc50 (patch) | |
| tree | aca172356d014bf541bf0098bd41e8ca656bf704 | |
| parent | c7dc112d2ea49b652eab5818a5b7934587f0c9d9 (diff) | |
Fix for issue #185 "Shared Image reload() loses initial dimensions"
| -rw-r--r-- | src/Fl_Shared_Image.cxx | 16 |
1 files changed, 6 insertions, 10 deletions
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); } } |
