Skip to content

Commit

Permalink
hopefully fix endianness, again
Browse files Browse the repository at this point in the history
  • Loading branch information
Shnatsel committed Dec 19, 2024
1 parent 6d8703c commit 8f05026
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/alpha_blending.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
//!
//! https://github.com/webmproject/libwebp/blob/e4f7a9f0c7c9fbfae1568bc7fa5c94b989b50872/src/demux/anim_decode.c#L215-L267
#[cfg(target_endian = "big")]
fn channel_shift(i: u32) -> u32 {
24 - (i) * 8
}

#[cfg(target_endian = "little")]
fn channel_shift(i: u32) -> u32 {
i * 8
}
Expand Down Expand Up @@ -61,7 +55,7 @@ fn blend_pixel_nonpremult(src: u32, dst: u32) -> u32 {
}

pub(crate) fn do_alpha_blending(buffer: [u8; 4], canvas: [u8; 4]) -> [u8; 4] {
blend_pixel_nonpremult(u32::from_ne_bytes(buffer), u32::from_ne_bytes(canvas)).to_ne_bytes()
blend_pixel_nonpremult(u32::from_le_bytes(buffer), u32::from_le_bytes(canvas)).to_le_bytes()
}

/// Divides by 255, rounding to nearest (as opposed to down, like regular integer division does).
Expand Down

0 comments on commit 8f05026

Please sign in to comment.