sw_engine: rectified 8 grayscale drawing

8 bits matting images must be blended, not overwriting.

issue: https://github.com/thorvg/thorvg/issues/1767
This commit is contained in:
Hermet Park 2024-09-12 19:12:26 +09:00
parent 38dbd86d12
commit 36f5a8fd4e

View file

@ -1338,11 +1338,13 @@ static bool _rasterDirectMattedImage(SwSurface* surface, const SwImage* image, c
auto src = sbuffer;
if (opacity == 255) {
for (uint32_t x = 0; x < w; ++x, ++dst, ++src, cmp += csize) {
*dst = MULTIPLY(A(*src), alpha(cmp));
auto tmp = MULTIPLY(A(*src), alpha(cmp));
*dst = tmp + MULTIPLY(*dst, 255 - tmp);
}
} else {
for (uint32_t x = 0; x < w; ++x, ++dst, ++src, cmp += csize) {
*dst = MULTIPLY(A(*src), MULTIPLY(opacity, alpha(cmp)));
auto tmp = MULTIPLY(A(*src), MULTIPLY(opacity, alpha(cmp)));
*dst = tmp + MULTIPLY(*dst, 255 - tmp);
}
}
buffer += surface->stride;