Apply clippy::if_not_else

This commit is contained in:
Luracasmus 2025-11-22 19:59:36 +01:00 committed by Alejandro González
parent 59b916e736
commit ead0097fef
No known key found for this signature in database
2 changed files with 9 additions and 9 deletions

View file

@ -44,9 +44,7 @@ impl IhdrData {
(w * bpp).div_ceil(8) * h (w * bpp).div_ceil(8) * h
} }
if !self.interlaced { if self.interlaced {
bitmap_size(bpp, w, h) + h
} else {
let mut size = bitmap_size(bpp, (w + 7) >> 3, (h + 7) >> 3) + ((h + 7) >> 3); let mut size = bitmap_size(bpp, (w + 7) >> 3, (h + 7) >> 3) + ((h + 7) >> 3);
if w > 4 { if w > 4 {
size += bitmap_size(bpp, (w + 3) >> 3, (h + 7) >> 3) + ((h + 7) >> 3); size += bitmap_size(bpp, (w + 3) >> 3, (h + 7) >> 3) + ((h + 7) >> 3);
@ -60,6 +58,8 @@ impl IhdrData {
size += bitmap_size(bpp, w >> 1, (h + 1) >> 1) + ((h + 1) >> 1); size += bitmap_size(bpp, w >> 1, (h + 1) >> 1) + ((h + 1) >> 1);
} }
size + bitmap_size(bpp, w, h >> 1) + (h >> 1) size + bitmap_size(bpp, w, h >> 1) + (h >> 1)
} else {
bitmap_size(bpp, w, h) + h
} }
} }
} }

View file

@ -54,10 +54,10 @@ pub fn reduced_to_indexed(png: &PngImage, allow_grayscale: bool) -> Option<PngIm
let transparency_pixel = transparent_shade.map(|t| Gray::from(t as u8)); let transparency_pixel = transparent_shade.map(|t| Gray::from(t as u8));
pmap.into_iter() pmap.into_iter()
.map(|px| { .map(|px| {
RGB::from(px).with_alpha(if Some(px) != transparency_pixel { RGB::from(px).with_alpha(if Some(px) == transparency_pixel {
255
} else {
0 0
} else {
255
}) })
}) })
.collect() .collect()
@ -68,10 +68,10 @@ pub fn reduced_to_indexed(png: &PngImage, allow_grayscale: bool) -> Option<PngIm
let transparency_pixel = transparent_color.map(|t| t.map(|c| c as u8)); let transparency_pixel = transparent_color.map(|t| t.map(|c| c as u8));
pmap.into_iter() pmap.into_iter()
.map(|px| { .map(|px| {
px.with_alpha(if Some(px) != transparency_pixel { px.with_alpha(if Some(px) == transparency_pixel {
255
} else {
0 0
} else {
255
}) })
}) })
.collect() .collect()