diff --git a/src/Tools/tim_tool/src/logic/tim.rs b/src/Tools/tim_tool/src/logic/tim.rs index cfdb26c3..64ea2f1e 100644 --- a/src/Tools/tim_tool/src/logic/tim.rs +++ b/src/Tools/tim_tool/src/logic/tim.rs @@ -25,10 +25,6 @@ impl TIMInfo { let mut image_data = SharedPixelBuffer::new(frame_info.width, frame_info.height); let mut dst_pixels = image_data.make_mut_slice(); - if bytes_per_pixel != 3 && bytes_per_pixel != 4 { - return Err(Error::from_text(format!("Image has {} bytes per pixel, but only 3 and 4 bytes per pixel are supported", bytes_per_pixel))); - } - if info.color_type == png::ColorType::Indexed { let palette = info.palette.ok_or(Error::from_str("Found indexed PNG without palette"))?; let mut palette_colors = Vec::new(); @@ -54,8 +50,12 @@ impl TIMInfo { } Ok(TIMInfo{image_data, palette: Some(palette_colors)}) } - + else { + if bytes_per_pixel != 3 && bytes_per_pixel != 4 { + return Err(Error::from_text(format!("Image has {} bytes per pixel, but only 3 and 4 bytes per pixel are supported", bytes_per_pixel))); + } + let mut byte_iter = buffer.iter(); while let Some(color) = make_color(&mut byte_iter, bytes_per_pixel == 4) { match bit_depth {