fn next_interlaced_row_impl(&mut self) -> Result<Option<InterlacedRow<'_>>, DecodingError> {
        use crate::common::ColorType::*;
        let transform = self.transform;

        if transform == crate::Transformations::IDENTITY {
            return self.next_raw_interlaced_row();
        }

        // swap buffer to circumvent borrow issues
        let mut buffer = mem::replace(&mut self.processed, Vec::new());
        let (got_next, adam7) = if let Some(row) = self.next_raw_interlaced_row()? {
            (&mut buffer[..]).write_all(row.data)?;
            (true, row.interlace)
        } else {
            (false, InterlaceInfo::None)
        };
        // swap back
        let _ = mem::replace(&mut self.processed, buffer);

        if !got_next {
            return Ok(None);
        }

        let (color_type, bit_depth, trns) = {
            let info = get_info!(self);
            (info.color_type, info.bit_depth as u8, info.trns.is_some())
        };
        let output_buffer = if let InterlaceInfo::Adam7 { width, .. } = adam7 {
            let width = self.line_size(width);
            &mut self.processed[..width]
        } else {
            &mut *self.processed
        };

        let mut len = output_buffer.len();
        if transform.contains(crate::Transformations::EXPAND) {
            match color_type {
                Indexed => expand_paletted(output_buffer, get_info!(self))?,
                Grayscale | GrayscaleAlpha if bit_depth < 8 => {
                    expand_gray_u8(output_buffer, get_info!(self))
                }
                Grayscale | RGB if trns => {
                    let channels = color_type.samples();
                    let trns = get_info!(self).trns.as_ref().unwrap();
                    if bit_depth == 8 {
                        utils::expand_trns_line(output_buffer, &*trns, channels);
                    } else {
                        utils::expand_trns_line16(output_buffer, &*trns, channels);
                    }
                }
                _ => (),
            }
        }

        if bit_depth == 16
            && transform
                .intersects(crate::Transformations::SCALE_16 | crate::Transformations::STRIP_16)
        {
            len /= 2;
            for i in 0..len {
                output_buffer[i] = output_buffer[2 * i];
            }
        }

        Ok(Some(InterlacedRow {
            data: &output_buffer[..len],
            interlace: adam7,
        }))
    }
/// Fetch the next interlaced row and filter it according to our own transformations.
Fetch the next interlaced row and filter it according to our own transformations.
Fetch the next interlaced row and filter it according to our own transformations .
fn next_interlaced_row_impl(&mut self) -> Result<Option<InterlacedRow<'_>>, DecodingError> {
        use crate::common::ColorType::*;
        let transform = self.transform;
        if transform == crate::Transformations::IDENTITY {
            return self.next_raw_interlaced_row();
        }
        // swap buffer to circumvent borrow issues
        let mut buffer = mem::replace(&mut self.processed, Vec::new());
        let (got_next, adam7) = if let Some(row) = self.next_raw_interlaced_row()? {
            (&mut buffer[..]).write_all(row.data)?;
            (true, row.interlace)
        } else {
            (false, InterlaceInfo::None)
        };
        // swap back
        let _ = mem::replace(&mut self.processed, buffer);
        if !got_next {
            return Ok(None);
        }
        let (color_type, bit_depth, trns) = {
            let info = get_info!(self);
            (info.color_type, info.bit_depth as u8, info.trns.is_some())
        };
        let output_buffer = if let InterlaceInfo::Adam7 { width, .. } = adam7 {
            let width = self.line_size(width);
            &mut self.processed[..width]
        } else {
            &mut *self.processed
        };
        let mut len = output_buffer.len();
        if transform.contains(crate::Transformations::EXPAND) {
            match color_type {
                Indexed => expand_paletted(output_buffer, get_info!(self))?,
                Grayscale | GrayscaleAlpha if bit_depth < 8 => {
                    expand_gray_u8(output_buffer, get_info!(self))
                }
                Grayscale | RGB if trns => {
                    let channels = color_type.samples();
                    let trns = get_info!(self).trns.as_ref().unwrap();
                    if bit_depth == 8 {
                        utils::expand_trns_line(output_buffer, &*trns, channels);
                    } else {
                        utils::expand_trns_line16(output_buffer, &*trns, channels);
                    }
                }
                _ => (),
            }
        }
        if bit_depth == 16
            && transform
                .intersects(crate::Transformations::SCALE_16 | crate::Transformations::STRIP_16)
        {
            len /= 2;
            for i in 0..len {
                output_buffer[i] = output_buffer[2 * i];
            }
        }
        Ok(Some(InterlacedRow {
            data: &output_buffer[..len],
            interlace: adam7,
        }))
    }
fn next_interlaced_row_impl ( & mut self ) -> Result < Option < InterlacedRow < ' _ > > , DecodingError > { use crate :: common :: ColorType :: * ; let transform = self . transform ; if transform == crate :: Transformations :: IDENTITY { return self . next_raw_interlaced_row ( ) ; } // swap buffer to circumvent borrow issues let mut buffer = mem :: replace ( & mut self . processed , Vec :: new ( ) ) ; let ( got_next , adam7 ) = if let Some ( row ) = self . next_raw_interlaced_row ( ) ? { ( & mut buffer [ .. ] ) . write_all ( row . data ) ? ; ( true , row . interlace ) } else { ( false , InterlaceInfo :: None ) } ; // swap back let _ = mem :: replace ( & mut self . processed , buffer ) ; if ! got_next { return Ok ( None ) ; } let ( color_type , bit_depth , trns ) = { let info = get_info ! ( self ) ; ( info . color_type , info . bit_depth as u8 , info . trns . is_some ( ) ) } ; let output_buffer = if let InterlaceInfo :: Adam7 { width , .. } = adam7 { let width = self . line_size ( width ) ; & mut self . processed [ .. width ] } else { & mut * self . processed } ; let mut len = output_buffer . len ( ) ; if transform . contains ( crate :: Transformations :: EXPAND ) { match color_type { Indexed => expand_paletted ( output_buffer , get_info ! ( self ) ) ? , Grayscale | GrayscaleAlpha if bit_depth < 8 => { expand_gray_u8 ( output_buffer , get_info ! ( self ) ) } Grayscale | RGB if trns => { let channels = color_type . samples ( ) ; let trns = get_info ! ( self ) . trns . as_ref ( ) . unwrap ( ) ; if bit_depth == 8 { utils :: expand_trns_line ( output_buffer , & * trns , channels ) ; } else { utils :: expand_trns_line16 ( output_buffer , & * trns , channels ) ; } } _ => ( ) , } } if bit_depth == 16 && transform . intersects ( crate :: Transformations :: SCALE_16 | crate :: Transformations :: STRIP_16 ) { len /= 2 ; for i in 0 .. len { output_buffer [ i ] = output_buffer [ 2 * i ] ; } } Ok ( Some ( InterlacedRow { data : & output_buffer [ .. len ] , interlace : adam7 , } ) ) }
Fetch the next interlaced row and filter it according to our own transformations.
Fetch the next interlaced row and filter it according to our own transformations .
&mut self
&mut self