Skip to content

Commit

Permalink
fix: normalize colors at rgba_to_argb
Browse files Browse the repository at this point in the history
More info can be found at: jrmuizel/raqote#167
  • Loading branch information
l4l committed Dec 10, 2020
1 parent ebc0aef commit 335e575
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/icon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,13 @@ fn rgba_to_argb(buf: &[u8]) -> Vec<u32> {
let mut data = vec![];

for chunk in buf.chunks(4) {
let a = u32::from(chunk[3]) << 24;
let r = u32::from(chunk[0]) << 16;
let g = u32::from(chunk[1]) << 8;
let b = u32::from(chunk[2]);
let src =
raqote::SolidSource::from_unpremultiplied_argb(chunk[3], chunk[0], chunk[1], chunk[2]);

let a = u32::from(src.a) << 24;
let r = u32::from(src.r) << 16;
let g = u32::from(src.g) << 8;
let b = u32::from(src.b);

data.push(a | r | g | b);
}
Expand Down

0 comments on commit 335e575

Please sign in to comment.