Skip to main content

ScanlineDecoder

Trait ScanlineDecoder 

Source
pub trait ScanlineDecoder {
    // Required methods
    fn width(&self) -> u32;
    fn height(&self) -> u32;
    fn count_comps(&self) -> u8;
    fn bpc(&self) -> u8;
    fn row_stride(&self) -> usize;
    fn decode_scanline(&mut self) -> Result<Option<&[u8]>, DecodeError>;
    fn reset(&mut self) -> Result<(), DecodeError>;
    fn current_line(&self) -> Option<usize>;
}
Expand description

A scanline-based image decoder that yields one row of pixels at a time.

After construction, call decode_scanline repeatedly to get each row. Returns Ok(None) after the last row. Call reset to restart from the first row.

Mirrors PDFium’s ScanlineDecoder base class interface, including the image-geometry accessors GetWidth(), GetHeight(), CountComps(), and GetBPC().

Required Methods§

Source

fn width(&self) -> u32

Image width in pixels. Mirrors PDFium’s GetWidth().

Source

fn height(&self) -> u32

Image height in pixels. Mirrors PDFium’s GetHeight().

Source

fn count_comps(&self) -> u8

Number of color components per pixel (e.g. 1 for gray, 3 for RGB, 4 for CMYK). Mirrors PDFium’s CountComps().

Source

fn bpc(&self) -> u8

Bits per color component (e.g. 1, 8, 16). Mirrors PDFium’s GetBPC().

Source

fn row_stride(&self) -> usize

Number of bytes per row: (width * count_comps * bpc + 7) / 8.

Source

fn decode_scanline(&mut self) -> Result<Option<&[u8]>, DecodeError>

Decode and return the next scanline.

Returns Ok(Some(data)) for each row, Ok(None) when all rows are done.

Source

fn reset(&mut self) -> Result<(), DecodeError>

Reset the decoder to the first scanline.

Source

fn current_line(&self) -> Option<usize>

Current line index (0-based), or None if no lines have been read yet.

Implementors§