summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2017-12-27 11:02:14 +0000
committerManolo Gouy <Manolo>2017-12-27 11:02:14 +0000
commit7aa6b582ee209105dc31a54fa49591ee1af83488 (patch)
tree567879f580c49e479130ea92754a2e84defb6f64 /src
parentc6045962dba33eb86e13bc416fa76a7a21b93be5 (diff)
Support for GUI rescaling: fix fl_copy_offscreen() to PostScript surface under X11.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12608 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Graphics_Driver.cxx23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/Fl_Graphics_Driver.cxx b/src/Fl_Graphics_Driver.cxx
index ea330f17a..6bbc8acb6 100644
--- a/src/Fl_Graphics_Driver.cxx
+++ b/src/Fl_Graphics_Driver.cxx
@@ -85,18 +85,25 @@ void Fl_Graphics_Driver::copy_offscreen(int x, int y, int w, int h, Fl_Offscreen
Fl_Image_Surface *surface = NULL;
int px_width = w, px_height = h;
Fl::screen_driver()->offscreen_size(pixmap, px_width, px_height);
- int px = srcx, py = srcy, pw = w, ph = h;
- if (px < 0) {px = 0; pw += srcx; x -= srcx;}
- if (py < 0) {py = 0; ph += srcy; y -= srcy;}
- if (px + pw > px_width) {pw = px_width - px;}
- if (py + ph > px_height) {ph = px_height - py;}
Fl_Surface_Device *current = Fl_Surface_Device::surface();
- fl_begin_offscreen(pixmap);
- // test whether pixmap was not created by fl_create_offscreen()
- if (current == Fl_Surface_Device::surface()) {
+ fl_begin_offscreen(pixmap); // does nothing if pixmap was not created by fl_create_offscreen()
+ float s = 1;
+ if (current == Fl_Surface_Device::surface()) {// pixmap was not created by fl_create_offscreen()
+ // happens, e.g., when drawing images under WIN32
surface = new Fl_Image_Surface(px_width, px_height, 0, pixmap);
Fl_Surface_Device::push_current(surface);
}
+ else { // pixmap was created by fl_create_offscreen()
+ Fl_Image_Surface *imgs = (Fl_Image_Surface*)Fl_Surface_Device::surface();
+ int sw, sh;
+ imgs->printable_rect(&sw, &sh);
+ s = px_width / float(sw);
+ }
+ int px = srcx, py = srcy, pw = w, ph = h;
+ if (px < 0) {px = 0; pw += srcx; x -= srcx;}
+ if (py < 0) {py = 0; ph += srcy; y -= srcy;}
+ if (px + pw > px_width/s) {pw = px_width/s - px;}
+ if (py + ph > px_height/s) {ph = px_height/s - py;}
uchar *img = fl_read_image(NULL, px, py, pw, ph, 0);
if (surface) {
Fl_Surface_Device::pop_current();