diff --git a/FL/Fl_Image_Surface.H b/FL/Fl_Image_Surface.H index 1daf4bc63..e411822c9 100644 --- a/FL/Fl_Image_Surface.H +++ b/FL/Fl_Image_Surface.H @@ -86,7 +86,7 @@ public: void origin(int x, int y); int printable_rect(int *w, int *h); Fl_Offscreen offscreen(); - static void rescale(Fl_Image_Surface*& surf); + void rescale(); }; diff --git a/src/Fl_Image_Surface.cxx b/src/Fl_Image_Surface.cxx index 07afef0d6..7fa4da631 100644 --- a/src/Fl_Image_Surface.cxx +++ b/src/Fl_Image_Surface.cxx @@ -118,16 +118,18 @@ Fl_Offscreen Fl_Image_Surface::get_offscreen_before_delete_() { return keep; } -/** Adapts an Fl_Image_Surface object to the new value of the GUI scale factor. +/** Adapts the Fl_Image_Surface object to the new value of the GUI scale factor. + The Fl_Image_Surface object must not be the current drawing surface. + This function is useful only for an object constructed with non-zero \p high_res parameter. \version 1.4 */ -void Fl_Image_Surface::rescale(Fl_Image_Surface*& surface) { - Fl_RGB_Image *rgb = surface->image(); +void Fl_Image_Surface::rescale() { + Fl_RGB_Image *rgb = image(); int w, h; - surface->printable_rect(&w, &h); - delete surface; - surface = new Fl_Image_Surface(w, h, 1); - Fl_Surface_Device::push_current(surface); + printable_rect(&w, &h); + delete platform_surface; + platform_surface = Fl_Image_Surface_Driver::newImageSurfaceDriver(w, h, 1, 0); + Fl_Surface_Device::push_current(this); rgb->draw(0,0); Fl_Surface_Device::pop_current(); delete rgb; @@ -170,7 +172,7 @@ static int find_slot(void) { // return an available slot to memorize an Fl_Image