pub(super) fn adam7_interlace(
    out: &mut [u8],
    inp: &[u8],
    w: u32,
    h: u32,
    bpp: u32,
) {
    let (passw, passh, _, _, passstart) = adam7_get_pass_values(w, h, bpp);
    let bpp = bpp as usize;
    if bpp >= 8 {
        for i in 0..7 {
            let bytewidth = bpp / 8;
            for y in 0..passh[i] as usize {
                for x in 0..passw[i] as usize {
                    let pixelinstart = ((ADAM7_IY[i] as usize
                        + y * ADAM7_DY[i] as usize)
                        * w as usize
                        + ADAM7_IX[i] as usize
                        + x * ADAM7_DX[i] as usize)
                        * bytewidth;
                    let pixeloutstart = passstart[i] as usize
                        + (y * passw[i] as usize + x) * bytewidth;
                    out[pixeloutstart..(bytewidth + pixeloutstart)]
                        .clone_from_slice(
                            &inp[pixelinstart..(bytewidth + pixelinstart)],
                        );
                }
            }
        }
    } else {
        for i in 0..7 {
            let ilinebits = bpp * passw[i] as usize;
            let olinebits = bpp * w as usize;
            for y in 0..passh[i] as usize {
                for x in 0..passw[i] as usize {
                    let mut ibp = (ADAM7_IY[i] as usize
                        + y * ADAM7_DY[i] as usize)
                        * olinebits
                        + (ADAM7_IX[i] as usize + x * ADAM7_DX[i] as usize)
                            * bpp;
                    let mut obp = ((8 * passstart[i] as usize)
                        + (y * ilinebits + x * bpp));
                    for _ in 0..bpp {
                        let bit = read_bit_from_reversed_stream(&mut ibp, inp);
                        set_bit_of_reversed_stream(&mut obp, out, bit);
                    }
                }
            }
        }
    };
}
/*
in: non-interlaced image with size w*h
out: the same pixels, but re-ordered according to PNG's Adam7 interlacing, with
 no padding bits between scanlines, but between reduced images so that each
 reduced image starts at a byte.
bpp: bits per pixel
there are no padding bits, not between scanlines, not between reduced images
in has the following size in bits: w * h * bpp.
out is possibly bigger due to padding bits between reduced images
NOTE: comments about padding bits are only relevant if bpp < 8
*/
non-interlaced image with size w*h
out: the same pixels, but re-ordered according to PNG's Adam7 interlacing, with
no padding bits between scanlines, but between reduced images so that each
reduced image starts at a byte.
bpp: bits per pixel
there are no padding bits, not between scanlines, not between reduced images
in has the following size in bits: w * h * bpp.
out is possibly bigger due to padding bits between reduced images
NOTE: comments about padding bits are only relevant if bpp < 8
non - interlaced image with size w * h out : the same pixels but re - ordered according to PNG ' s Adam7 interlacing with no padding bits between scanlines but between reduced images so that each reduced image starts at a byte . bpp : bits per pixel there are no padding bits not between scanlines not between reduced images in has the following size in bits : w * h * bpp . out is possibly bigger due to padding bits between reduced images NOTE : comments about padding bits are only relevant if bpp < 8
pub(super) fn adam7_interlace(
    out: &mut [u8],
    inp: &[u8],
    w: u32,
    h: u32,
    bpp: u32,
) {
    let (passw, passh, _, _, passstart) = adam7_get_pass_values(w, h, bpp);
    let bpp = bpp as usize;
    if bpp >= 8 {
        for i in 0..7 {
            let bytewidth = bpp / 8;
            for y in 0..passh[i] as usize {
                for x in 0..passw[i] as usize {
                    let pixelinstart = ((ADAM7_IY[i] as usize
                        + y * ADAM7_DY[i] as usize)
                        * w as usize
                        + ADAM7_IX[i] as usize
                        + x * ADAM7_DX[i] as usize)
                        * bytewidth;
                    let pixeloutstart = passstart[i] as usize
                        + (y * passw[i] as usize + x) * bytewidth;
                    out[pixeloutstart..(bytewidth + pixeloutstart)]
                        .clone_from_slice(
                            &inp[pixelinstart..(bytewidth + pixelinstart)],
                        );
                }
            }
        }
    } else {
        for i in 0..7 {
            let ilinebits = bpp * passw[i] as usize;
            let olinebits = bpp * w as usize;
            for y in 0..passh[i] as usize {
                for x in 0..passw[i] as usize {
                    let mut ibp = (ADAM7_IY[i] as usize
                        + y * ADAM7_DY[i] as usize)
                        * olinebits
                        + (ADAM7_IX[i] as usize + x * ADAM7_DX[i] as usize)
                            * bpp;
                    let mut obp = ((8 * passstart[i] as usize)
                        + (y * ilinebits + x * bpp));
                    for _ in 0..bpp {
                        let bit = read_bit_from_reversed_stream(&mut ibp, inp);
                        set_bit_of_reversed_stream(&mut obp, out, bit);
                    }
                }
            }
        }
    };
}
pub ( super ) fn adam7_interlace ( out : & mut [ u8 ] , inp : & [ u8 ] , w : u32 , h : u32 , bpp : u32 , ) { let ( passw , passh , _ , _ , passstart ) = adam7_get_pass_values ( w , h , bpp ) ; let bpp = bpp as usize ; if bpp >= 8 { for i in 0 .. 7 { let bytewidth = bpp / 8 ; for y in 0 .. passh [ i ] as usize { for x in 0 .. passw [ i ] as usize { let pixelinstart = ( ( ADAM7_IY [ i ] as usize + y * ADAM7_DY [ i ] as usize ) * w as usize + ADAM7_IX [ i ] as usize + x * ADAM7_DX [ i ] as usize ) * bytewidth ; let pixeloutstart = passstart [ i ] as usize + ( y * passw [ i ] as usize + x ) * bytewidth ; out [ pixeloutstart .. ( bytewidth + pixeloutstart ) ] . clone_from_slice ( & inp [ pixelinstart .. ( bytewidth + pixelinstart ) ] , ) ; } } } } else { for i in 0 .. 7 { let ilinebits = bpp * passw [ i ] as usize ; let olinebits = bpp * w as usize ; for y in 0 .. passh [ i ] as usize { for x in 0 .. passw [ i ] as usize { let mut ibp = ( ADAM7_IY [ i ] as usize + y * ADAM7_DY [ i ] as usize ) * olinebits + ( ADAM7_IX [ i ] as usize + x * ADAM7_DX [ i ] as usize ) * bpp ; let mut obp = ( ( 8 * passstart [ i ] as usize ) + ( y * ilinebits + x * bpp ) ) ; for _ in 0 .. bpp { let bit = read_bit_from_reversed_stream ( & mut ibp , inp ) ; set_bit_of_reversed_stream ( & mut obp , out , bit ) ; } } } } } ; }
in: non-interlaced image with size w*h
out: the same pixels, but re-ordered according to PNG's Adam7 interlacing, with
no padding bits between scanlines, but between reduced images so that each
reduced image starts at a byte.
in : non - interlaced image with size w * h out : the same pixels but re - ordered according to PNG ' s Adam7 interlacing with no padding bits between scanlines but between reduced images so that each reduced image starts at a byte .
out
&mut [u8]
inp
&[u8]
w
u32
h
u32
bpp
u32