summaryrefslogtreecommitdiff
path: root/src/Fl_Bitmap.cxx
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2022-04-12 15:06:21 +0200
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2022-04-12 15:06:21 +0200
commitbfae813c4e15ec0a45a7b2cdecf32c3aac2776eb (patch)
treed91e1a1e34a05a71e12a498751ae3c1cf3e3e829 /src/Fl_Bitmap.cxx
parentfad867a5d37b5162255a338f5f5218ff852f8852 (diff)
Fix for issue #427: Problems with data_w, data_h, w, h of Fl_Image.
Diffstat (limited to 'src/Fl_Bitmap.cxx')
-rw-r--r--src/Fl_Bitmap.cxx12
1 files changed, 6 insertions, 6 deletions
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;