FLTK logo

[master] 871e706 - Windows: restore "checkers" app that was damaged after handling of issue #155.

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] 871e706 - Windows: restore "checkers" app that was damaged after handling of issue #155. "ManoloFLTK" Jan 25, 2021  
 
commit 871e7063a27706b22921536232797e43d513793a
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Mon Jan 25 18:57:50 2021 +0100
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Mon Jan 25 18:58:05 2021 +0100

    Windows: restore "checkers" app that was damaged after handling of issue #155.

 src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx
index 246f98c..38bfc4b 100644
--- src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx
+++ src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx
@@ -543,14 +543,21 @@ void Fl_GDI_Graphics_Driver::draw_rgb(Fl_RGB_Image *rgb, int XP, int YP, int WP,
   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;
+  int cx2 = cx * scale(), cy2 = cy * scale();
+  if (cx2+Wfull > rgb->data_w()) Wfull = rgb->data_w()-cx2;
+  if (cy2+Hfull > rgb->data_h()) Hfull = rgb->data_h()-cy2;
+  float scaleW = float(rgb->data_w())/rgb->w();
+  float scaleH = float(rgb->data_h())/rgb->h();
+  if (Wfull > int(WP*scaleW)) Wfull = int(WP*scaleW);
+  if (Hfull > int(HP*scaleH)) Hfull = int(HP*scaleH);
+  if (rgb->as_svg_image()) { // maintain precise aspect ratio for SVG images
+    float s = scale(); scale(1); cache_size(rgb, Wfull, Hfull); scale(s);
+  }
   if ( (rgb->d() % 2) == 0 ) {
-    alpha_blend_(XP*scale(), YP*scale(), W, H, new_gc, cx, cy, Wfull, Hfull);
+    alpha_blend_(XP*scale(), YP*scale(), W, H, new_gc, cx*scaleW, cy*scaleH, Wfull, Hfull);
   } else {
     SetStretchBltMode(gc_, HALFTONE);
-    StretchBlt(gc_, XP*scale(), YP*scale(), W, H, new_gc, cx, cy, Wfull, Hfull, SRCCOPY);
+    StretchBlt(gc_, XP*scale(), YP*scale(), W, H, new_gc, cx*scaleW, cy*scaleH, Wfull, Hfull, SRCCOPY);
   }
   RestoreDC(new_gc, save);
   DeleteDC(new_gc);
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.