summaryrefslogtreecommitdiffstats
path: root/tiny_skia
diff options
context:
space:
mode:
Diffstat (limited to 'tiny_skia')
-rw-r--r--tiny_skia/src/vector.rs17
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