From e25758582e49c1887fcde4c16da761428fe6f5fa Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Wed, 13 Apr 2022 09:30:31 +0200 Subject: Fix for issue #427 - continued. --- src/Fl_Image.cxx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/Fl_Image.cxx') diff --git a/src/Fl_Image.cxx b/src/Fl_Image.cxx index 0ecfa7e6e..eba5b2001 100644 --- a/src/Fl_Image.cxx +++ b/src/Fl_Image.cxx @@ -407,29 +407,28 @@ Fl_Image *Fl_RGB_Image::copy(int W, int H) { // Optimize the simple copy where the width and height are the same, // or when we are copying an empty image... - if ((W == w() && H == h()) || + if ((W == data_w() && H == data_h()) || !w() || !h() || !d() || !array) { if (array) { // Make a copy of the image data and return a new Fl_RGB_Image... - new_array = new uchar[data_w() * data_h() * d()]; - if (ld() && ld()!=data_w()*d()) { + new_array = new uchar[W * H * d()]; + if (ld() && (ld() != W *d())) { const uchar *src = array; uchar *dst = new_array; - int dy, dh = data_h(), wd = data_w()*d(), wld = ld(); + int dy, dh = H, wd = W*d(), wld = ld(); for (dy=0; dyalloc_array = 1; } else { - new_image = new Fl_RGB_Image(array, data_w(), data_h(), d(), ld()); + new_image = new Fl_RGB_Image(array, W, H, d(), ld()); } - new_image->scale(w(), h(), 0, 1); return new_image; } if (W <= 0 || H <= 0) return 0; -- cgit v1.2.3