Skip to content

Commit

Permalink
Fix compilation on 1.35
Browse files Browse the repository at this point in the history
  • Loading branch information
aschampion committed Dec 4, 2019
1 parent d8f6163 commit b6369c4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ pub enum ChannelsType {
impl ChannelsType {
pub fn channel_count(self) -> u8 {
match self {
Self::L => 1,
Self::La => 2,
Self::Rgb => 3,
Self::Rgba => 4,
Self::Bgr => 3,
Self::Bgra => 4,
Self::__Nonexhaustive => unreachable!(),
ChannelsType::L => 1,
ChannelsType::La => 2,
ChannelsType::Rgb => 3,
ChannelsType::Rgba => 4,
ChannelsType::Bgr => 3,
ChannelsType::Bgra => 4,
ChannelsType::__Nonexhaustive => unreachable!(),
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/png.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@ impl<'a, R: 'a + Read> ImageDecoder<'a> for PngDecoder<R> {
let bpc = self.color_type().bytes_per_pixel() / self.color_type().channel_count();
match bpc {
1 => (), // No reodering necessary for u8
2 => buf.chunks_mut(2).for_each(|c| NativeEndian::write_u16(c, BigEndian::read_u16(c))),
2 => buf.chunks_mut(2).for_each(|c| {
let v = BigEndian::read_u16(c);
NativeEndian::write_u16(c, v)
}),
_ => unreachable!(),
}
Ok(())
Expand Down

0 comments on commit b6369c4

Please sign in to comment.