diff options
author | 2023-05-10 01:56:25 +0200 | |
---|---|---|
committer | 2023-05-10 01:56:25 +0200 | |
commit | 422b4dedcbc9af22ebc9e40e7902549a6919ce16 (patch) | |
tree | bdbf8e2ae5ac72f18e08c980fe07dcbab781be48 /tiny_skia | |
parent | 22e82dd5d65e21d2c1861e16f718bb15f027a00e (diff) | |
parent | 3f1c8a8d288d823529e81124bd514f626e84c610 (diff) | |
download | iced-422b4dedcbc9af22ebc9e40e7902549a6919ce16.tar.gz iced-422b4dedcbc9af22ebc9e40e7902549a6919ce16.tar.bz2 iced-422b4dedcbc9af22ebc9e40e7902549a6919ce16.zip |
Merge pull request #1841 from wash2/fix-svg-color-filter
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 |