FLTK logo

[master] 28aaa4d - Simplify source code of Fl_GDI_Graphics_Driver::draw_rgb(Fl_RGB_Image *,…)

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] 28aaa4d - Simplify source code of Fl_GDI_Graphics_Driver::draw_rgb(Fl_RGB_Image *,…) "ManoloFLTK" Feb 22, 2021  
 
commit 28aaa4d4ce6e7c766995c1d2dca9ac6b3c82b6b7
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Mon Feb 22 11:34:02 2021 +0100
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Mon Feb 22 11:34:14 2021 +0100

    Simplify source code of Fl_GDI_Graphics_Driver::draw_rgb(Fl_RGB_Image *,â?¦)

 src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx
index 5bb5157..0135eb6 100644
--- src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx
+++ src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx
@@ -536,32 +536,25 @@ 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);
   }
+  bool need_clip = (cx || cy || WP != rgb->w() || HP != rgb->h());
+  if (need_clip) {
+    push_clip(XP, YP, WP, HP);
+    XP -= cx; YP -= cy; cx = cy = 0; WP = rgb->w(); HP = 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 = int(W * (rgb->data_w() / float(Wfull))); Hfull = int(H * (rgb->data_h() / float(Hfull)));
-  int cx2 = int(cx * scale()), cy2 = int(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_(int(XP*scale()), int(YP*scale()), W, H, new_gc, int(cx*scaleW), int(cy*scaleH), Wfull, Hfull);
+    alpha_blend_(int(XP*scale()), int(YP*scale()), W, H, new_gc, 0, 0, rgb->data_w(), rgb->data_h());
   } else {
     SetStretchBltMode(gc_, HALFTONE);
-    StretchBlt(gc_, int(XP*scale()), int(YP*scale()), W, H, new_gc, int(cx*scaleW), int(cy*scaleH), Wfull, Hfull, SRCCOPY);
+    StretchBlt(gc_, int(XP*scale()), int(YP*scale()), W, H, new_gc, 0, 0, rgb->data_w(), rgb->data_h(), SRCCOPY);
   }
   RestoreDC(new_gc, save);
   DeleteDC(new_gc);
+  if (need_clip) pop_clip();
 }
 
 
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'.