summaryrefslogtreecommitdiff
path: root/src/Fl_SVG_Image.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_SVG_Image.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_SVG_Image.cxx')
-rw-r--r--src/Fl_SVG_Image.cxx25
1 files changed, 3 insertions, 22 deletions
diff --git a/src/Fl_SVG_Image.cxx b/src/Fl_SVG_Image.cxx
index 3c528170c..a0116ba53 100644
--- a/src/Fl_SVG_Image.cxx
+++ b/src/Fl_SVG_Image.cxx
@@ -193,7 +193,6 @@ void Fl_SVG_Image::rasterize_(int W, int H) {
rasterized_ = true;
raster_w_ = W;
raster_h_ = H;
-//printf("rasterize to %dx%d\n",W, H);
}
@@ -235,10 +234,7 @@ void Fl_SVG_Image::resize(int width, int height) {
void Fl_SVG_Image::draw(int X, int Y, int W, int H, int cx, int cy) {
- float f = 1;
- if (Fl_Surface_Device::surface() == Fl_Display_Device::display_device()) {
- f = Fl::screen_driver()->retina_factor() * fl_graphics_driver->scale();
- }
+ float f = Fl::screen_driver()->retina_factor() * fl_graphics_driver->scale();
int w1 = w(), h1 = h();
/* When f > 1, there may be several pixels per FLTK unit in an area
of size w() x h() of the display. This occurs, e.g., with Apple retina displays
@@ -248,15 +244,8 @@ void Fl_SVG_Image::draw(int X, int Y, int W, int H, int cx, int cy) {
the SVG image is drawn using the full resolution of the display.
*/
resize(f*w(), f*h());
- if (f == 1) {
- Fl_RGB_Image::draw(X, Y, W, H, cx, cy);
- } else {
- bool need_clip = (cx || cy || W != w1 || H != h1);
- if (need_clip) fl_push_clip(X, Y, W, H);
- fl_graphics_driver->draw_scaled(this, X-cx, Y-cy, w1, h1);
- if (need_clip) fl_pop_clip();
- w(w1); h(h1); // restore the previous image size
- }
+ scale(w1, h1, 0, 1);
+ Fl_RGB_Image::draw(X, Y, W, H, cx, cy);
}
@@ -272,14 +261,6 @@ void Fl_SVG_Image::color_average(Fl_Color c, float i) {
Fl_RGB_Image::color_average(c, i);
}
-
-int Fl_SVG_Image::draw_scaled(int X, int Y, int W, int H) {
- w(W);
- h(H);
- draw(X, Y, W, H, 0, 0);
- return 1;
-}
-
#endif // FLTK_USE_NANOSVG
//