Fix divide-by-zero crash when using calligraphy tool (d34276f8) · Commits · Inkscape / inkscape · GitLab
Martin Owens
·
2026-05-16
·
via Martin Owens activity
When getting the average color of a cairo surface, if the alpha is
zero, we were getting a divide-by-zero error, because we were
dividing r, g, and b by the cumulutive alpha of the surface.
Instead, we should return black in that case.
Fixes #6098
| Original line number |
Diff line number |
Diff line |
|
@@ -1304,6 +1304,9 @@ Colors::Color ink_cairo_surface_average_color(cairo_surface_t *surface, cairo_su |
|
|
{
|
|
|
double r, g, b, a = 0.0;
|
|
|
double count = ink_cairo_surface_average_color_internal(surface, mask, r, g, b, a);
|
|
|
if (a == 0.0) {
|
|
|
return Colors::Color(Colors::Space::Type::RGB, {0, 0, 0, 0});
|
|
|
}
|
|
|
auto color = Colors::Color(Colors::Space::Type::RGB, {r / a, g / a, b / a, a / count});
|
|
|
color.normalize();
|
|
|
return color;
|
|
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。