Allow the use of Fl_Image_Surface::image() also when the Fl_Image_Surface object is not the current drawing surface.

This fixes an issue uncovered in a thread of fltk.general entitled
fl_pop_clip: clip stack underflow! warning on X11

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12222 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2017-04-24 09:23:33 +00:00
parent da31ffd952
commit d91b3d80e5

View File

@ -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).