diff options
Diffstat (limited to 'Userland/Applications/PixelPaint/Image.cpp')
-rw-r--r-- | Userland/Applications/PixelPaint/Image.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Userland/Applications/PixelPaint/Image.cpp b/Userland/Applications/PixelPaint/Image.cpp index 191dd512af..4c9d88db41 100644 --- a/Userland/Applications/PixelPaint/Image.cpp +++ b/Userland/Applications/PixelPaint/Image.cpp @@ -532,4 +532,19 @@ void Image::crop(Gfx::IntRect const& cropped_rect) did_change_rect(cropped_rect); } +Color Image::color_at(Gfx::IntPoint const& point) const +{ + Color color; + for (auto& layer : m_layers) { + if (!layer.is_visible() || !layer.rect().contains(point)) + continue; + + auto layer_color = layer.bitmap().get_pixel(point); + float layer_opacity = layer.opacity_percent() / 100.0f; + layer_color.set_alpha((u8)(layer_color.alpha() * layer_opacity)); + color = color.blend(layer_color); + } + return color; +} + } |