mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:17:45 +00:00
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.
This commit is contained in:
parent
dc34ecf394
commit
545b4879e4
1 changed files with 4 additions and 2 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue