fix: tiny-skia svg premultiply final filtered color
This commit is contained in:
parent
9a8b30d7e9
commit
3f1c8a8d28
1 changed files with 9 additions and 8 deletions
|
|
@ -141,18 +141,19 @@ impl Cache {
|
|||
image.as_mut(),
|
||||
)?;
|
||||
|
||||
if let Some([r, g, b, a]) = key.color {
|
||||
// TODO: Blend alpha
|
||||
let color = tiny_skia::ColorU8::from_rgba(b, g, r, a)
|
||||
.premultiply()
|
||||
.get()
|
||||
& 0x00FFFFFF;
|
||||
|
||||
if let Some([r, g, b, _]) = key.color {
|
||||
// Apply color filter
|
||||
for pixel in
|
||||
bytemuck::cast_slice_mut::<u8, u32>(image.data_mut())
|
||||
{
|
||||
*pixel = *pixel & 0xFF000000 | color;
|
||||
*pixel = tiny_skia::ColorU8::from_rgba(
|
||||
b,
|
||||
g,
|
||||
r,
|
||||
(*pixel >> 24) as u8,
|
||||
)
|
||||
.premultiply()
|
||||
.get();
|
||||
}
|
||||
} else {
|
||||
// Swap R and B channels for `softbuffer` presentation
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue