From ea27dafe1e38dc7a3501088d56e016011a6ec166 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Mon, 9 Mar 2026 12:17:10 +0100 Subject: [PATCH] Fix "Transparent PNGs not rendered correctly when window is scaled" (#1375) --- src/Fl_Image.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Fl_Image.cxx b/src/Fl_Image.cxx index 4727da018..991773cbd 100644 --- a/src/Fl_Image.cxx +++ b/src/Fl_Image.cxx @@ -892,7 +892,13 @@ void Fl_RGB_Image::draw(int XP, int YP, int WP, int HP, int cx, int cy) { // fl_max(cx, 0),fl_max(cy, 0) = top-left of drawn part in image. int l = (ld() ? ld() : d() * w()); const uchar *p = array + fl_max(cy, 0) * l + fl_max(cx, 0) * d(); - fl_graphics_driver->draw_image(p, r1.x, r1.y, r1.width, r1.height, d(), l); + if (d() % 2) { // use draw_image() without transparenvy + fl_graphics_driver->draw_image(p, r1.x, r1.y, r1.width, r1.height, d(), l); + } else { // with transparency, build temporary RGB image and draw it + Fl_RGB_Image *temp_rgb = new Fl_RGB_Image(p, r1.width, r1.height, d(), l); + fl_graphics_driver->draw_rgb(temp_rgb, r1.x, r1.y, r1.width, r1.height, 0, 0); + delete temp_rgb; + } } else fl_graphics_driver->draw_rgb(this, XP, YP, WP, HP, cx, cy); }