pub(super) fn postprocess_scanlines(
    out: &mut [u8],
    inp: &mut [u8],
    w: u32,
    h: u32,
    info_png: &Info,
) -> Result<(), Error> {
    let bpp = info_png.color.bpp();
    if bpp == 0 {
        return Err(Error(31));
    }
    if info_png.interlace_method == 0 {
        if bpp < 8
            && w as usize * bpp as usize
                != ((w as usize * bpp as usize + 7) / 8) * 8
        {
            unfilter_aliased(inp, 0, 0, w as usize, h as usize, bpp as usize)?;
            remove_padding_bits(
                out,
                inp,
                w as usize * bpp as usize,
                ((w as usize * bpp as usize + 7) / 8) * 8,
                h as usize,
            );
        } else {
            unfilter(out, inp, w, h, bpp)?;
        };
    } else {
        let (passw, passh, filter_passstart, padded_passstart, passstart) =
            adam7_get_pass_values(w, h, bpp);
        for i in 0..7 {
            unfilter_aliased(
                inp,
                padded_passstart[i] as usize,
                filter_passstart[i] as usize,
                passw[i] as usize,
                passh[i] as usize,
                bpp as usize,
            )?;
            if bpp < 8 {
                /*remove padding bits in scanlines; after this there still may be padding
                bits between the different reduced images: each reduced image still starts nicely at a byte*/
                remove_padding_bits_aliased(
                    inp,
                    passstart[i] as usize,
                    padded_passstart[i] as usize,
                    passw[i] as usize * bpp as usize,
                    ((passw[i] as usize * bpp as usize + 7) / 8) * 8,
                    passh[i] as usize,
                );
            };
        }
        adam7_deinterlace(out, inp, w, h, bpp.try_into().unwrap());
    }
    Ok(())
}
/*
This function converts the filtered-padded-interlaced data into pure 2D image buffer with the PNG's colortype.
Steps:
*) if no Adam7: 1) unfilter 2) remove padding bits (= posible extra bits per scanline if bpp < 8)
*) if adam7: 1) 7x unfilter 2) 7x remove padding bits 3) adam7_deinterlace
NOTE: the in buffer will be overwritten with intermediate data!
*/
This function converts the filtered-padded-interlaced data into pure 2D image buffer with the PNG's colortype.
Steps:
) if no Adam7: 1) unfilter 2) remove padding bits (= posible extra bits per scanline if bpp < 8)
) if adam7: 1) 7x unfilter 2) 7x remove padding bits 3) adam7_deinterlace
NOTE: the in buffer will be overwritten with intermediate data!
This function converts the filtered - padded - interlaced data into pure 2D image buffer with the PNG ' s colortype . Steps : ) if no Adam7 : 1 ) unfilter 2 ) remove padding bits ( = posible extra bits per scanline if bpp < 8 ) ) if adam7 : 1 ) 7x unfilter 2 ) 7x remove padding bits 3 ) adam7_deinterlace NOTE : the in buffer will be overwritten with intermediate data!
pub(super) fn postprocess_scanlines(
    out: &mut [u8],
    inp: &mut [u8],
    w: u32,
    h: u32,
    info_png: &Info,
) -> Result<(), Error> {
    let bpp = info_png.color.bpp();
    if bpp == 0 {
        return Err(Error(31));
    }
    if info_png.interlace_method == 0 {
        if bpp < 8
            && w as usize * bpp as usize
                != ((w as usize * bpp as usize + 7) / 8) * 8
        {
            unfilter_aliased(inp, 0, 0, w as usize, h as usize, bpp as usize)?;
            remove_padding_bits(
                out,
                inp,
                w as usize * bpp as usize,
                ((w as usize * bpp as usize + 7) / 8) * 8,
                h as usize,
            );
        } else {
            unfilter(out, inp, w, h, bpp)?;
        };
    } else {
        let (passw, passh, filter_passstart, padded_passstart, passstart) =
            adam7_get_pass_values(w, h, bpp);
        for i in 0..7 {
            unfilter_aliased(
                inp,
                padded_passstart[i] as usize,
                filter_passstart[i] as usize,
                passw[i] as usize,
                passh[i] as usize,
                bpp as usize,
            )?;
            if bpp < 8 {
                /*remove padding bits in scanlines; after this there still may be padding
                bits between the different reduced images: each reduced image still starts nicely at a byte*/
                remove_padding_bits_aliased(
                    inp,
                    passstart[i] as usize,
                    padded_passstart[i] as usize,
                    passw[i] as usize * bpp as usize,
                    ((passw[i] as usize * bpp as usize + 7) / 8) * 8,
                    passh[i] as usize,
                );
            };
        }
        adam7_deinterlace(out, inp, w, h, bpp.try_into().unwrap());
    }
    Ok(())
}
pub ( super ) fn postprocess_scanlines ( out : & mut [ u8 ] , inp : & mut [ u8 ] , w : u32 , h : u32 , info_png : & Info , ) -> Result < ( ) , Error > { let bpp = info_png . color . bpp ( ) ; if bpp == 0 { return Err ( Error ( 31 ) ) ; } if info_png . interlace_method == 0 { if bpp < 8 && w as usize * bpp as usize != ( ( w as usize * bpp as usize + 7 ) / 8 ) * 8 { unfilter_aliased ( inp , 0 , 0 , w as usize , h as usize , bpp as usize ) ? ; remove_padding_bits ( out , inp , w as usize * bpp as usize , ( ( w as usize * bpp as usize + 7 ) / 8 ) * 8 , h as usize , ) ; } else { unfilter ( out , inp , w , h , bpp ) ? ; } ; } else { let ( passw , passh , filter_passstart , padded_passstart , passstart ) = adam7_get_pass_values ( w , h , bpp ) ; for i in 0 .. 7 { unfilter_aliased ( inp , padded_passstart [ i ] as usize , filter_passstart [ i ] as usize , passw [ i ] as usize , passh [ i ] as usize , bpp as usize , ) ? ; if bpp < 8 { /*remove padding bits in scanlines; after this there still may be padding
                bits between the different reduced images: each reduced image still starts nicely at a byte*/ remove_padding_bits_aliased ( inp , passstart [ i ] as usize , padded_passstart [ i ] as usize , passw [ i ] as usize * bpp as usize , ( ( passw [ i ] as usize * bpp as usize + 7 ) / 8 ) * 8 , passh [ i ] as usize , ) ; } ; } adam7_deinterlace ( out , inp , w , h , bpp . try_into ( ) . unwrap ( ) ) ; } Ok ( ( ) ) }
This function converts the filtered-padded-interlaced data into pure 2D image buffer with the PNG's colortype.
This function converts the filtered - padded - interlaced data into pure 2D image buffer with the PNG ' s colortype .
out
&mut [u8]
inp
&mut [u8]
w
u32
h
u32
info_png
&Info