Fix for indexed images not loading anymore
This commit is contained in:
parent
7a7b710ca4
commit
ac6a46134e
|
@ -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();
|
||||
|
@ -56,6 +52,10 @@ impl TIMInfo {
|
|||
}
|
||||
|
||||
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 {
|
||||
|
|
Loading…
Reference in New Issue