mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-04 15:45:25 +00:00
LibGUI: Fix ColorPicker custom color offset
Previously the ColorPicker would get the custom color directly from the
window, this was changed in d7d5788469 to
get the color from the underlying bitmap instead - without taking the
bitmap's scaling into effect though, so resulting colors were off by
quite a bit.
Fixes #3113.
This commit is contained in:
committed by
Andreas Kling
parent
728d4649e4
commit
675d8eec60
@@ -418,7 +418,10 @@ void CustomColorWidget::pick_color_at_position(GUI::MouseEvent& event)
|
||||
if (!frame_inner_rect().contains(position))
|
||||
return;
|
||||
|
||||
auto color = m_custom_colors->get_pixel(position);
|
||||
// Map actual event position onto scaled bitmap to get the right pixel
|
||||
auto pixel_x = min(position.x() * m_custom_colors->width() / frame_inner_rect().width(), m_custom_colors->width() - 1);
|
||||
auto pixel_y = min(position.y() * m_custom_colors->height() / frame_inner_rect().height(), m_custom_colors->height() - 1);
|
||||
auto color = m_custom_colors->get_pixel({ pixel_x, pixel_y });
|
||||
m_last_position = position;
|
||||
|
||||
if (on_pick)
|
||||
|
||||
Reference in New Issue
Block a user