From 545b4879e43472f92bcee5e9142f41cd5fd88e32 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Tue, 12 Jan 2021 21:00:04 +0100 Subject: [PATCH] LibGfx: Make Painter::draw_pixel() with thickness = 1 work with RGBA The underlying fill_rect() works correctly, but the special case for thickness = 1 was not blending the new color with the target pixel's color, causing RGBA colors to be painted as their RGB counterpart. --- Userland/Libraries/LibGfx/Painter.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibGfx/Painter.cpp b/Userland/Libraries/LibGfx/Painter.cpp index 7e7f5f16c7..ab2c06d171 100644 --- a/Userland/Libraries/LibGfx/Painter.cpp +++ b/Userland/Libraries/LibGfx/Painter.cpp @@ -1157,8 +1157,10 @@ ALWAYS_INLINE void Painter::fill_scanline_with_draw_op(int y, int x, int width, void Painter::draw_pixel(const IntPoint& position, Color color, int thickness) { - if (thickness == 1) - return set_pixel_with_draw_op(m_target->scanline(position.y())[position.x()], color); + if (thickness == 1) { + auto& pixel = m_target->scanline(position.y())[position.x()]; + return set_pixel_with_draw_op(pixel, Color::from_rgba(pixel).blend(color)); + } IntRect rect { position.translated(-(thickness / 2), -(thickness / 2)), { thickness, thickness } }; fill_rect(rect.translated(-state().translation), color); }