pub(super) fn read_chunk_bkgd(
    info: &mut Info,
    data: &[u8],
) -> Result<(), Error> {
    let chunk_length = data.len();
    if info.color.colortype == ColorType::Palette {
        /*error: this chunk must be 1 byte for indexed color image*/
        if chunk_length != 1 {
            return Err(Error(43)); /*error: this chunk must be 2 bytes for greyscale image*/
        } /*error: this chunk must be 6 bytes for greyscale image*/
        info.background_defined = 1; /* OK */
        info.background_r = {
            info.background_g = {
                info.background_b = data[0] as u32;
                info.background_b
            };
            info.background_g
        };
    } else if info.color.colortype == ColorType::Grey
        || info.color.colortype == ColorType::GreyAlpha
    {
        if chunk_length != 2 {
            return Err(Error(44));
        }
        info.background_defined = 1;
        info.background_r = {
            info.background_g = {
                info.background_b = 256 * data[0] as u32 + data[1] as u32;
                info.background_b
            };
            info.background_g
        };
    } else if info.color.colortype == ColorType::Rgb
        || info.color.colortype == ColorType::Rgba
    {
        if chunk_length != 6 {
            return Err(Error(45));
        }
        info.background_defined = 1;
        info.background_r = 256 * data[0] as u32 + data[1] as u32;
        info.background_g = 256 * data[2] as u32 + data[3] as u32;
        info.background_b = 256 * data[4] as u32 + data[5] as u32;
    }
    Ok(())
}
/*background color chunk (bKGD)*/
background color chunk (bKGD)
background color chunk ( bKGD )
pub(super) fn read_chunk_bkgd(
    info: &mut Info,
    data: &[u8],
) -> Result<(), Error> {
    let chunk_length = data.len();
    if info.color.colortype == ColorType::Palette {
        /*error: this chunk must be 1 byte for indexed color image*/
        if chunk_length != 1 {
            return Err(Error(43)); /*error: this chunk must be 2 bytes for greyscale image*/
        } /*error: this chunk must be 6 bytes for greyscale image*/
        info.background_defined = 1; /* OK */
        info.background_r = {
            info.background_g = {
                info.background_b = data[0] as u32;
                info.background_b
            };
            info.background_g
        };
    } else if info.color.colortype == ColorType::Grey
        || info.color.colortype == ColorType::GreyAlpha
    {
        if chunk_length != 2 {
            return Err(Error(44));
        }
        info.background_defined = 1;
        info.background_r = {
            info.background_g = {
                info.background_b = 256 * data[0] as u32 + data[1] as u32;
                info.background_b
            };
            info.background_g
        };
    } else if info.color.colortype == ColorType::Rgb
        || info.color.colortype == ColorType::Rgba
    {
        if chunk_length != 6 {
            return Err(Error(45));
        }
        info.background_defined = 1;
        info.background_r = 256 * data[0] as u32 + data[1] as u32;
        info.background_g = 256 * data[2] as u32 + data[3] as u32;
        info.background_b = 256 * data[4] as u32 + data[5] as u32;
    }
    Ok(())
}
pub ( super ) fn read_chunk_bkgd ( info : & mut Info , data : & [ u8 ] , ) -> Result < ( ) , Error > { let chunk_length = data . len ( ) ; if info . color . colortype == ColorType :: Palette { /*error: this chunk must be 1 byte for indexed color image*/ if chunk_length != 1 { return Err ( Error ( 43 ) ) ; /*error: this chunk must be 2 bytes for greyscale image*/ } /*error: this chunk must be 6 bytes for greyscale image*/ info . background_defined = 1 ; /* OK */ info . background_r = { info . background_g = { info . background_b = data [ 0 ] as u32 ; info . background_b } ; info . background_g } ; } else if info . color . colortype == ColorType :: Grey || info . color . colortype == ColorType :: GreyAlpha { if chunk_length != 2 { return Err ( Error ( 44 ) ) ; } info . background_defined = 1 ; info . background_r = { info . background_g = { info . background_b = 256 * data [ 0 ] as u32 + data [ 1 ] as u32 ; info . background_b } ; info . background_g } ; } else if info . color . colortype == ColorType :: Rgb || info . color . colortype == ColorType :: Rgba { if chunk_length != 6 { return Err ( Error ( 45 ) ) ; } info . background_defined = 1 ; info . background_r = 256 * data [ 0 ] as u32 + data [ 1 ] as u32 ; info . background_g = 256 * data [ 2 ] as u32 + data [ 3 ] as u32 ; info . background_b = 256 * data [ 4 ] as u32 + data [ 5 ] as u32 ; } Ok ( ( ) ) }
background color chunk (bKGD)
background color chunk ( bKGD )
info
&mut Info
data
&[u8]