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_Bitmap.cxx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/Fl_Bitmap.cxx') diff --git a/src/Fl_Bitmap.cxx b/src/Fl_Bitmap.cxx index 4767c7815..f760ac979 100644 --- a/src/Fl_Bitmap.cxx +++ b/src/Fl_Bitmap.cxx @@ -60,13 +60,12 @@ Fl_Image *Fl_Bitmap::copy(int W, int H) { uchar *new_array; // New array for image data // Optimize the simple copy where the width and height are the same... - if (W == w() && H == h()) { - new_array = new uchar [data_h() * ((data_w() + 7) / 8)]; - memcpy(new_array, array, data_h() * ((data_w() + 7) / 8)); + if (W == data_w() && H == data_h()) { + new_array = new uchar [H * ((W + 7) / 8)]; + memcpy(new_array, array, H * ((W + 7) / 8)); - new_image = new Fl_Bitmap(new_array, data_w(), data_h()); + new_image = new Fl_Bitmap(new_array, W, H); new_image->alloc_array = 1; - new_image->scale(w(), h(), 0, 1); return new_image; } if (W <= 0 || H <= 0) return 0; -- cgit v1.2.3