Skip to main content

ProgressiveDecoder

Struct ProgressiveDecoder 

Source
pub struct ProgressiveDecoder { /* private fields */ }
Expand description

Decoder that supports scan-by-scan progressive output.

Progressive JPEGs encode image data in multiple scans, each refining the image quality. This decoder lets you consume scans one at a time and output the best available reconstruction at any point.

Implementations§

Source§

impl ProgressiveDecoder

Source

pub fn new(data: &[u8]) -> Result<Self>

Create from JPEG data. Returns error if not a progressive JPEG. Applies crate::common::types::DecodeLimits::default; use Self::with_limits to tighten (e.g. a max_memory ceiling for the coefficient buffers this decoder holds across scans).

Source

pub fn with_limits(data: &[u8], limits: DecodeLimits) -> Result<Self>

Like Self::new with caller-chosen resource limits, applied from marker parsing onward (issue #355).

Source

pub fn has_multiple_scans(&self) -> bool

Check if the JPEG has multiple scans (i.e., is progressive).

Source

pub fn num_scans(&self) -> usize

Get total number of scans in the image.

Source

pub fn width(&self) -> usize

Get image width in pixels.

Source

pub fn height(&self) -> usize

Get image height in pixels.

Source

pub fn consume_input(&mut self) -> Result<bool>

Consume the next scan from input. Returns true if a scan was consumed, false if all scans are done.

Source

pub fn input_complete(&self) -> bool

Check if all input scans have been consumed.

Source

pub fn scans_consumed(&self) -> usize

Get the number of scans consumed so far.

Source

pub fn output(&self) -> Result<Image>

Output the current image state (after consuming some scans). Returns the best available reconstruction from scans consumed so far. Each call to consume_input() followed by output() gives a progressively better image.

Source

pub fn finish(self) -> Result<Image>

Consume all remaining scans and output the final image. Equivalent to calling consume_input() in a loop then output().

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.