mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:17:34 +00:00
PixelPaint: Account for alpha in color distance calculation
This fixes an issue where BucketTool would consider "black" and "transparent" the same color.
This commit is contained in:
parent
21ae882cfd
commit
0506f4eef8
1 changed files with 3 additions and 1 deletions
|
@ -2,6 +2,7 @@
|
||||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||||
* Copyright (c) 2022, Aaron Yoder <aaronjyoder@gmail.com>
|
* Copyright (c) 2022, Aaron Yoder <aaronjyoder@gmail.com>
|
||||||
* Copyright (c) 2022, the SerenityOS developers.
|
* Copyright (c) 2022, the SerenityOS developers.
|
||||||
|
* Copyright (c) 2022, Timothy Slater <tslater2006@gmail.com>.
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -30,7 +31,8 @@ static float color_distance_squared(Gfx::Color const& lhs, Gfx::Color const& rhs
|
||||||
int a = rhs.red() - lhs.red();
|
int a = rhs.red() - lhs.red();
|
||||||
int b = rhs.green() - lhs.green();
|
int b = rhs.green() - lhs.green();
|
||||||
int c = rhs.blue() - lhs.blue();
|
int c = rhs.blue() - lhs.blue();
|
||||||
return (a * a + b * b + c * c) / (3.0f * 255.0f * 255.0f);
|
int d = rhs.alpha() - lhs.alpha();
|
||||||
|
return (a * a + b * b + c * c + d * d) / (4.0f * 255.0f * 255.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool can_paint(int x, int y, Gfx::Bitmap& bitmap, Gfx::Color const& target_color, float threshold_normalized_squared)
|
static bool can_paint(int x, int y, Gfx::Bitmap& bitmap, Gfx::Color const& target_color, float threshold_normalized_squared)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue