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
This commit is contained in:
Manolo Gouy
2017-05-18 17:26:34 +00:00
parent f48750b0f4
commit f2c27b5090
3 changed files with 26 additions and 3 deletions
+1
View File
@@ -512,6 +512,7 @@ FL_EXPORT Fl_Offscreen fl_create_offscreen(int w, int h);
FL_EXPORT void fl_begin_offscreen(Fl_Offscreen b);
FL_EXPORT void fl_end_offscreen(void);
FL_EXPORT void fl_delete_offscreen(Fl_Offscreen bitmap);
FL_EXPORT void fl_scale_offscreen(Fl_Offscreen &ctx);
/** @} */
+24
View File
@@ -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();
}
/** @} */
+1 -3
View File
@@ -114,9 +114,7 @@ int oscr_box::handle(int ev)
int ret = Fl_Box::handle(ev);
if (ev == FL_HIDE && oscr) {
fl_delete_offscreen(oscr);
oscr = 0;
iters = num_iterations + 1;
fl_scale_offscreen(oscr);
}
// handle dragging of visible page area - if a valid context exists
if (has_oscr())