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