pub struct JpegDecoder<S>where
S: Source,{ /* private fields */ }Expand description
Decodes a JPEG stream.
Baseline frames stream one MCU row at a time. Progressive frames decode
their scans into a coefficient buffer first and are then served the same
way; the distinction is not visible through Decoder.
Implementations§
Source§impl<S> JpegDecoder<S>where
S: Source,
impl<S> JpegDecoder<S>where
S: Source,
Sourcepub fn new(source: S, limits: Limits) -> Result<JpegDecoder<S>, PixelsError>
pub fn new(source: S, limits: Limits) -> Result<JpegDecoder<S>, PixelsError>
Read every header up to and including the scan header.
No coefficient is decoded here, baseline or progressive, so this is the
probe()/metadata path as well as the start of a decode (SPEC
§Guarantees 3).
§Errors
Returns PixelsError::Malformed for a stream that is not a
well-formed JPEG, PixelsError::Unsupported for a variant this crate
does not handle (arithmetic coding, lossless, 12-bit, CMYK), or
PixelsError::LimitExceeded if the frame exceeds limits.
Sourcepub fn with_scale(
source: S,
limits: Limits,
scale: Scale,
) -> Result<JpegDecoder<S>, PixelsError>
pub fn with_scale( source: S, limits: Limits, scale: Scale, ) -> Result<JpegDecoder<S>, PixelsError>
Read every header, and decode at a reduced resolution.
At M/8 scale the decoder inverse-transforms only the low-frequency
corner of each block, so a thumbnail costs a fraction of the arithmetic
and — the point of it — the full-resolution image is never
materialized. Entropy decoding is unchanged: every coefficient is still
read, because the format gives no way to skip one.
Decoder::descriptor reports the scaled size, so a caller that
asks for a reduced decode is told what it will actually receive.
§Errors
As JpegDecoder::new.
Sourcepub const fn scale(&self) -> Scale
pub const fn scale(&self) -> Scale
The resolution this decoder produces, as eighths of full size.
Sourcepub const fn is_progressive(&self) -> bool
pub const fn is_progressive(&self) -> bool
Whether this stream is a progressive frame.
Trait Implementations§
Source§impl<S> Debug for JpegDecoder<S>
impl<S> Debug for JpegDecoder<S>
Source§impl<S> Decoder for JpegDecoder<S>
impl<S> Decoder for JpegDecoder<S>
Source§fn icc_profile(&self) -> Option<&[u8]>
fn icc_profile(&self) -> Option<&[u8]>
The ICC profile, joined from its APP2 segments.
Source§fn xmp(&self) -> Option<&[u8]>
fn xmp(&self) -> Option<&[u8]>
The XMP packet, from the first XMP APP1 segment. The extended XMP
a packet over 64 KB spills into is not joined.
Source§fn source_info(&self) -> SourceInfo
fn source_info(&self) -> SourceInfo
Progressive, chroma subsampling, density (JFIF, else EXIF) and
COM comments before the first scan.
Source§fn orientation(&self) -> Orientation
fn orientation(&self) -> Orientation
The EXIF orientation, from the first EXIF APP1 segment.
Source§fn descriptor(&self) -> ImageDescriptor
fn descriptor(&self) -> ImageDescriptor
Source§fn capability(&self) -> DecodeCapability
fn capability(&self) -> DecodeCapability
Source§fn reduced_descriptor(&self, target: (u32, u32)) -> Option<ImageDescriptor>
fn reduced_descriptor(&self, target: (u32, u32)) -> Option<ImageDescriptor>
target or larger, when
the format lets it reach that size more cheaply than a full decode. Read moreSource§fn reduce_to(&mut self, descriptor: ImageDescriptor) -> Result<(), PixelsError>
fn reduce_to(&mut self, descriptor: ImageDescriptor) -> Result<(), PixelsError>
Source§fn read_row(&mut self, out: &mut [u8]) -> Result<(), PixelsError>
fn read_row(&mut self, out: &mut [u8]) -> Result<(), PixelsError>
out. Read moreSource§fn animation(&self) -> Option<Animation>
fn animation(&self) -> Option<Animation>
Source§fn read_region(
&mut self,
region: Region,
out: &mut TileMut<'_>,
) -> Result<(), PixelsError>
fn read_region( &mut self, region: Region, out: &mut TileMut<'_>, ) -> Result<(), PixelsError>
out. Read more