From bfae813c4e15ec0a45a7b2cdecf32c3aac2776eb Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Tue, 12 Apr 2022 15:06:21 +0200 Subject: Fix for issue #427: Problems with data_w, data_h, w, h of Fl_Image. --- src/Fl_Bitmap.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/Fl_Bitmap.cxx') diff --git a/src/Fl_Bitmap.cxx b/src/Fl_Bitmap.cxx index c85b62803..4767c7815 100644 --- a/src/Fl_Bitmap.cxx +++ b/src/Fl_Bitmap.cxx @@ -1,7 +1,7 @@ // // Bitmap drawing routines for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2016 by Bill Spitzak and others. +// Copyright 1998-2022 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -60,13 +60,13 @@ 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 == data_w() && H == data_h()) { - new_array = new uchar [H * ((W + 7) / 8)]; - memcpy(new_array, array, H * ((W + 7) / 8)); + 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)); - new_image = new Fl_Bitmap(new_array, W, H); + new_image = new Fl_Bitmap(new_array, data_w(), data_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