From 069ab1b54fe658fa9b692d6a1a438e21b54acfa2 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Thu, 26 Apr 2018 09:05:20 +0000 Subject: Fix Fl_GDI_Graphics_Driver::copy_offscreen() when the destination surface is an Fl_Copy_Surface object. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12872 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/drivers') diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx index 694fcc59d..962b9ada5 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx @@ -22,7 +22,7 @@ #include #include #include - +#include /* * By linking this module, the following static method will instantiate the @@ -106,10 +106,18 @@ HDC fl_makeDC(HBITMAP bitmap) { } void Fl_GDI_Graphics_Driver::copy_offscreen(int x, int y, int w, int h, Fl_Offscreen bitmap, int srcx, int srcy) { + x *= scale(); y *= scale(); w *= scale(); h *= scale(); srcx *= scale(); srcy *= scale(); + if (srcx < 0) {w += srcx; x -= srcx; srcx = 0;} + if (srcy < 0) {h += srcy; y -= srcy; srcy = 0;} + int off_width, off_height; + Fl::screen_driver()->offscreen_size(bitmap, off_width, off_height); + if (srcx + w >= off_width) {w = off_width - srcx;} + if (srcy + h >= off_height) {h = off_height - srcy;} + if (w <= 0 || h <= 0) return; HDC new_gc = CreateCompatibleDC(gc_); int save = SaveDC(new_gc); SelectObject(new_gc, bitmap); - BitBlt(gc_, x*scale(), y*scale(), w*scale(), h*scale(), new_gc, srcx*scale(), srcy*scale(), SRCCOPY); + BitBlt(gc_, x, y, w, h, new_gc, srcx, srcy, SRCCOPY); RestoreDC(new_gc, save); DeleteDC(new_gc); } -- cgit v1.2.3