diff --git a/src/headers.rs b/src/headers.rs index f57de8c7..75a814f3 100644 --- a/src/headers.rs +++ b/src/headers.rs @@ -44,9 +44,7 @@ impl IhdrData { (w * bpp).div_ceil(8) * h } - if !self.interlaced { - bitmap_size(bpp, w, h) + h - } else { + if self.interlaced { let mut size = bitmap_size(bpp, (w + 7) >> 3, (h + 7) >> 3) + ((h + 7) >> 3); if w > 4 { 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, h >> 1) + (h >> 1) + } else { + bitmap_size(bpp, w, h) + h } } } diff --git a/src/reduction/color.rs b/src/reduction/color.rs index 0d1dde81..2836e656 100644 --- a/src/reduction/color.rs +++ b/src/reduction/color.rs @@ -54,10 +54,10 @@ pub fn reduced_to_indexed(png: &PngImage, allow_grayscale: bool) -> Option Option