Skip to content

Commit 3f1c8a8

Browse files
committed
fix: tiny-skia svg premultiply final filtered color
1 parent 9a8b30d commit 3f1c8a8

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

tiny_skia/src/vector.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,18 +141,19 @@ impl Cache {
141141
image.as_mut(),
142142
)?;
143143

144-
if let Some([r, g, b, a]) = key.color {
145-
// TODO: Blend alpha
146-
let color = tiny_skia::ColorU8::from_rgba(b, g, r, a)
147-
.premultiply()
148-
.get()
149-
& 0x00FFFFFF;
150-
144+
if let Some([r, g, b, _]) = key.color {
151145
// Apply color filter
152146
for pixel in
153147
bytemuck::cast_slice_mut::<u8, u32>(image.data_mut())
154148
{
155-
*pixel = *pixel & 0xFF000000 | color;
149+
*pixel = tiny_skia::ColorU8::from_rgba(
150+
b,
151+
g,
152+
r,
153+
(*pixel >> 24) as u8,
154+
)
155+
.premultiply()
156+
.get();
156157
}
157158
} else {
158159
// Swap R and B channels for `softbuffer` presentation

0 commit comments

Comments
 (0)