From 916b44e361f275555c5f22b9d91c973ccc089037 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Mon, 19 Mar 2018 17:43:18 +0000 Subject: 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 --- src/Fl_Pixmap.cxx | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src/Fl_Pixmap.cxx') diff --git a/src/Fl_Pixmap.cxx b/src/Fl_Pixmap.cxx index 54410a401..21d9e87a3 100644 --- a/src/Fl_Pixmap.cxx +++ b/src/Fl_Pixmap.cxx @@ -64,7 +64,7 @@ int Fl_Pixmap::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(), data()); + id_ = fl_graphics_driver->cache(this); } return 0; } @@ -153,7 +153,7 @@ 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 == pixel_w() && H == pixel_h()) { // Make an exact copy of the image and return it... new_image = new Fl_Pixmap(data()); new_image->copy_data(); @@ -185,10 +185,10 @@ Fl_Image *Fl_Pixmap::copy(int W, int H) { sprintf(new_info, "%d %d %d %d", W, H, ncolors, chars_per_pixel); // Figure out Bresenham step/modulus values... - xmod = w() % W; - xstep = (w() / W) * chars_per_pixel; - ymod = h() % H; - ystep = h() / H; + xmod = pixel_w() % W; + xstep = (pixel_w() / W) * chars_per_pixel; + ymod = pixel_h() % H; + ystep = pixel_h() / H; // Allocate memory for the new array... if (ncolors < 0) new_data = new char *[H + 2]; @@ -395,10 +395,6 @@ void Fl_Pixmap::desaturate() { } } -int Fl_Pixmap::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$". // -- cgit v1.2.3