From ac6a46134e0a289dffe4944567df77f7c576c27d Mon Sep 17 00:00:00 2001 From: Jaby Date: Sun, 16 Feb 2025 15:37:00 +0100 Subject: [PATCH] Fix for indexed images not loading anymore --- src/Tools/tim_tool/src/logic/tim.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 {