From c227edef39df37077efe979a1f7ab1a397487363 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Fri, 13 Nov 2020 10:02:33 +0100 Subject: Fix for issue #155 - continued This fix takes care of the Windows platform. --- src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx index 6bc9ad82d..246f98c81 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx @@ -535,18 +535,22 @@ void Fl_GDI_Graphics_Driver::draw_rgb(Fl_RGB_Image *rgb, int XP, int YP, int WP, if (!*Fl_Graphics_Driver::id(rgb)) { cache(rgb); } - float scaleW = float(rgb->data_w())/rgb->w(); - float scaleH = float(rgb->data_h())/rgb->h(); int W = WP, H = HP; cache_size(rgb, W, H); + int Wfull = rgb->w(), Hfull = rgb->h(); + cache_size(rgb, Wfull, Hfull); HDC new_gc = CreateCompatibleDC(gc_); int save = SaveDC(new_gc); SelectObject(new_gc, (HBITMAP)*Fl_Graphics_Driver::id(rgb)); + Wfull = W*(rgb->data_w()/float(Wfull)); Hfull = H*(rgb->data_h()/float(Hfull)); + cx *= scale(); cy *= scale(); + if (cx+Wfull > rgb->data_w()) Wfull = rgb->data_w()-cx; + if (cy+Hfull > rgb->data_h()) Hfull = rgb->data_h()-cy; if ( (rgb->d() % 2) == 0 ) { - alpha_blend_(XP*scale(), YP*scale(), W, H, new_gc, cx*scaleW, cy*scaleH, WP*scaleW, HP*scaleH); + alpha_blend_(XP*scale(), YP*scale(), W, H, new_gc, cx, cy, Wfull, Hfull); } else { SetStretchBltMode(gc_, HALFTONE); - StretchBlt(gc_, XP*scale(), YP*scale(), W, H, new_gc, cx*scaleW, cy*scaleH, WP*scaleW, HP*scaleH, SRCCOPY); + StretchBlt(gc_, XP*scale(), YP*scale(), W, H, new_gc, cx, cy, Wfull, Hfull, SRCCOPY); } RestoreDC(new_gc, save); DeleteDC(new_gc); -- cgit v1.2.3