summaryrefslogtreecommitdiff
path: root/src/Fl_Bitmap.cxx
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2018-03-19 17:43:18 +0000
committerManolo Gouy <Manolo>2018-03-19 17:43:18 +0000
commit916b44e361f275555c5f22b9d91c973ccc089037 (patch)
treea36b734804a82d3e5d4bd900bc9031b8fe60d35a /src/Fl_Bitmap.cxx
parentc4f7c09b7bacbfe19d1dcea5a28eeb30b1136a95 (diff)
New member function Fl_Image::scale(int width, int height) to set the FLTK size of an image.
Each image has now two sizes implemented as follows: - the pixel size is stored in private members pixel_w_ and pixel_h_ with public accessors pixel_w() and pixel_h() - the FLTK size is stored in private members w_ and h_ and read by w() and h() - when the image is constructed, the two sizes have the same value - the protected w(int) and h(int) member functions set both FLTK and pixel sizes. - the public scale(int, int) member function is essentially nothing but set the FLTK size and don't change the pixel size. - when the image is drawn, its FLTK size determines how big it is drawn, its pixel size determines how much data are available to draw it. FLTK 1.3.4 with FL_ABI_VERSION=10304 contained an equivalent member function but only for the Fl_Shared_Image class. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12776 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Bitmap.cxx')
-rw-r--r--src/Fl_Bitmap.cxx20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/Fl_Bitmap.cxx b/src/Fl_Bitmap.cxx
index c35a63538..4324b5367 100644
--- a/src/Fl_Bitmap.cxx
+++ b/src/Fl_Bitmap.cxx
@@ -125,7 +125,7 @@ int Fl_Bitmap::prepare(int XP, int YP, int WP, int HP, int &cx, int &cy,
}
if (fl_graphics_driver->start_image(this, XP,YP,WP,HP,cx,cy,X,Y,W,H)) return 1;
if (!id_)
- id_ = fl_graphics_driver->cache(this, w(), h(), array);
+ id_ = fl_graphics_driver->cache(this);
return 0;
}
@@ -158,7 +158,7 @@ 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()) {
+ if (W == pixel_w() && H == pixel_h()) {
new_array = new uchar [H * ((W + 7) / 8)];
memcpy(new_array, array, H * ((W + 7) / 8));
@@ -182,10 +182,10 @@ Fl_Image *Fl_Bitmap::copy(int W, int H) {
// Figure out Bresenham step/modulus values...
- xmod = w() % W;
- xstep = w() / W;
- ymod = h() % H;
- ystep = h() / H;
+ xmod = pixel_w() % W;
+ xstep = pixel_w() / W;
+ ymod = pixel_h() % H;
+ ystep = pixel_h() / H;
// Allocate memory for the new image...
new_array = new uchar [H * ((W + 7) / 8)];
@@ -196,7 +196,7 @@ Fl_Image *Fl_Bitmap::copy(int W, int H) {
// Scale the image using a nearest-neighbor algorithm...
for (dy = H, sy = 0, yerr = H, new_ptr = new_array; dy > 0; dy --) {
- for (dx = W, xerr = W, old_ptr = array + sy * ((w() + 7) / 8), sx = 0, new_bit = 1;
+ for (dx = W, xerr = W, old_ptr = array + sy * ((pixel_w() + 7) / 8), sx = 0, new_bit = 1;
dx > 0;
dx --) {
old_bit = (uchar)(1 << (sx & 7));
@@ -230,12 +230,6 @@ Fl_Image *Fl_Bitmap::copy(int W, int H) {
return new_image;
}
-
-int Fl_Bitmap::draw_scaled(int X, int Y, int W, int H) {
- return (W <= w() && H <= h()) ? fl_graphics_driver->draw_scaled(this, X, Y, W, H) : 0;
-}
-
-
//
// End of "$Id$".
//