summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2017-05-18 17:26:34 +0000
committerManolo Gouy <Manolo>2017-05-18 17:26:34 +0000
commitf2c27b5090314b318823b36cf5a74cb263239968 (patch)
tree2dea8d8b937f57ab22d94e14bd5e87f9867f8d78 /src
parentf48750b0f482a2155ec5d66b19110d2ac22ce87c (diff)
Add void fl_scale_offscreen(Fl_Offscreen &ctx) to support the rescaling of an offscreen buffer.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12240 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Image_Surface.cxx24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/Fl_Image_Surface.cxx b/src/Fl_Image_Surface.cxx
index c45ddbc16..63b0c18fc 100644
--- a/src/Fl_Image_Surface.cxx
+++ b/src/Fl_Image_Surface.cxx
@@ -178,6 +178,30 @@ void fl_end_offscreen() {
Fl_Surface_Device::pop_current();
}
+/** Adapts an offscreen buffer to a changed value of the graphical scaling factor.
+ The \p ctx argument must have been created by fl_create_offscreen()
+ and the calling context must not be between fl_begin_offscreen() and fl_end_offscreen().
+ */
+void fl_scale_offscreen(Fl_Offscreen &ctx) {
+ int i, w, h;
+ for (i = 0; i < count_offscreens; i++) {
+ if (offscreen_api_surface[i] && offscreen_api_surface[i]->offscreen() == ctx) {
+ break;
+ }
+ }
+ if (i >= count_offscreens) return;
+ Fl_RGB_Image *rgb = offscreen_api_surface[i]->image();
+ offscreen_api_surface[i]->printable_rect(&w, &h);
+ fl_delete_offscreen(ctx);
+ Fl_Shared_Image *shared = Fl_Shared_Image::get(rgb);
+ shared->scale(w, h, 0, 1);
+ ctx = fl_create_offscreen(w, h);
+ fl_begin_offscreen(ctx);
+ shared->draw(0, 0);
+ fl_end_offscreen();
+ shared->release();
+}
+
/** @} */