summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Image_Surface.cxx8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Fl_Image_Surface.cxx b/src/Fl_Image_Surface.cxx
index 632bc3de0..b8b50a2bc 100644
--- a/src/Fl_Image_Surface.cxx
+++ b/src/Fl_Image_Surface.cxx
@@ -77,7 +77,13 @@ int Fl_Image_Surface::printable_rect(int *w, int *h) {return platform_surface->
The returned object contains its own copy of the RGB data.
The caller is responsible for deleting the image.
*/
-Fl_RGB_Image *Fl_Image_Surface::image() {return platform_surface->image();}
+Fl_RGB_Image *Fl_Image_Surface::image() {
+ bool need_push = (Fl_Surface_Device::surface() != this);
+ if (need_push) Fl_Surface_Device::push_current(this);
+ Fl_RGB_Image *img = platform_surface->image();
+ if (need_push) Fl_Surface_Device::pop_current();
+ return img;
+}
/** Returns a possibly high resolution image made of all drawings sent to the Fl_Image_Surface object.
The Fl_Image_Surface object should have been constructed with Fl_Image_Surface(W, H, 1).