diff options
author | 2023-05-09 14:57:50 -0400 | |
---|---|---|
committer | 2023-05-09 14:57:50 -0400 | |
commit | 3f1c8a8d288d823529e81124bd514f626e84c610 (patch) | |
tree | e355a7aefc24f2a803273c17381813f414ba3bf4 /tiny_skia | |
parent | 9a8b30d7e9cf76c097d68c84736e7687b452d5c0 (diff) | |
download | iced-3f1c8a8d288d823529e81124bd514f626e84c610.tar.gz iced-3f1c8a8d288d823529e81124bd514f626e84c610.tar.bz2 iced-3f1c8a8d288d823529e81124bd514f626e84c610.zip |
fix: tiny-skia svg premultiply final filtered color
Diffstat (limited to 'tiny_skia')
-rw-r--r-- | tiny_skia/src/vector.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/tiny_skia/src/vector.rs b/tiny_skia/src/vector.rs index fc411fdd..a3f3c2e3 100644 --- a/tiny_skia/src/vector.rs +++ b/tiny_skia/src/vector.rs @@ -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 |