diff options
| -rw-r--r-- | src/Fl_Bitmap.cxx | 9 | ||||
| -rw-r--r-- | src/Fl_Image.cxx | 15 | ||||
| -rw-r--r-- | src/Fl_Pixmap.cxx | 3 |
3 files changed, 12 insertions, 15 deletions
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; 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; dy<dh; dy++) { memcpy(dst, src, wd); src += wld; dst += wd; } } else { - memcpy(new_array, array, data_w() * data_h() * d()); + memcpy(new_array, array, W * H * d()); } - new_image = new Fl_RGB_Image(new_array, data_w(), data_h(), d()); + new_image = new Fl_RGB_Image(new_array, W, H, d()); new_image->alloc_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; diff --git a/src/Fl_Pixmap.cxx b/src/Fl_Pixmap.cxx index 59e69bc97..e6c6cc4c3 100644 --- a/src/Fl_Pixmap.cxx +++ b/src/Fl_Pixmap.cxx @@ -131,11 +131,10 @@ Fl_Image *Fl_Pixmap::copy(int W, int H) { return new Fl_Pixmap((char *const*)0); } // Optimize the simple copy where the width and height are the same... - if (W == w() && H == h()) { + if (W == data_w() && H == data_h()) { // Make an exact copy of the image and return it... new_image = new Fl_Pixmap(data()); new_image->copy_data(); - new_image->scale(W, H, 0, 1); return new_image; } if (W <= 0 || H <= 0) return 0; |
