diff --git a/src/interlace.rs b/src/interlace.rs index 96b05fd3..b4670cf5 100644 --- a/src/interlace.rs +++ b/src/interlace.rs @@ -118,10 +118,8 @@ fn deinterlace_bits(png: &PngImage) -> Vec { let mut current_y: usize = pass_constants.y_shift as usize; for line in png.scan_lines(false) { let bit_vec = line.data.view_bits::(); - let bits_in_line = ((png.ihdr.width - u32::from(pass_constants.x_shift) - + u32::from(pass_constants.x_step) - - 1) - / u32::from(pass_constants.x_step)) as usize + let bits_in_line = (png.ihdr.width - u32::from(pass_constants.x_shift)) + .div_ceil(u32::from(pass_constants.x_step)) as usize * bits_per_pixel; for (i, bit) in bit_vec.iter().by_vals().enumerate() { // Avoid moving padded 0's into new image