Skip to content

Commit

Permalink
Faster alpha reduction
Browse files Browse the repository at this point in the history
  • Loading branch information
andrews05 committed Feb 3, 2025
1 parent 76d24ff commit 1b9e421
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/reduction/alpha.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ pub fn reduced_alpha_channel(png: &PngImage, optimize_alpha: bool) -> Option<Png
Some(trns) if pixel.iter().skip(colored_bytes).all(|b| *b == 0) => {
raw_data.resize(raw_data.len() + colored_bytes, trns);
}
_ => raw_data.extend_from_slice(&pixel[0..colored_bytes]),
_ if colored_bytes == 6 => raw_data.extend_from_slice(&pixel[0..6]),
_ if colored_bytes == 3 => raw_data.extend_from_slice(&pixel[0..3]),
_ if colored_bytes == 2 => raw_data.extend_from_slice(&pixel[0..2]),
_ => raw_data.push(pixel[0]),
};
}

Expand Down

0 comments on commit 1b9e421

Please sign in to comment.