Struct jpeg_decoder::Decoder
source · pub struct Decoder<R> {Show 17 fields
reader: R,
frame: Option<FrameInfo>,
dc_huffman_tables: Vec<Option<HuffmanTable>>,
ac_huffman_tables: Vec<Option<HuffmanTable>>,
quantization_tables: [Option<Arc<[u16; 64]>>; 4],
restart_interval: u16,
adobe_color_transform: Option<AdobeColorTransform>,
color_transform: Option<ColorTransform>,
is_jfif: bool,
is_mjpeg: bool,
icc_markers: Vec<IccChunk>,
exif_data: Option<Vec<u8>>,
xmp_data: Option<Vec<u8>>,
psir_data: Option<Vec<u8>>,
coefficients: Vec<Vec<i16>>,
coefficients_finished: [u64; 4],
decoding_buffer_size_limit: usize,
}
Expand description
JPEG decoder
Fields§
§reader: R
§frame: Option<FrameInfo>
§dc_huffman_tables: Vec<Option<HuffmanTable>>
§ac_huffman_tables: Vec<Option<HuffmanTable>>
§quantization_tables: [Option<Arc<[u16; 64]>>; 4]
§restart_interval: u16
§adobe_color_transform: Option<AdobeColorTransform>
§color_transform: Option<ColorTransform>
§is_jfif: bool
§is_mjpeg: bool
§icc_markers: Vec<IccChunk>
§exif_data: Option<Vec<u8>>
§xmp_data: Option<Vec<u8>>
§psir_data: Option<Vec<u8>>
§coefficients: Vec<Vec<i16>>
§coefficients_finished: [u64; 4]
§decoding_buffer_size_limit: usize
Implementations§
source§impl<R: Read> Decoder<R>
impl<R: Read> Decoder<R>
sourcepub fn set_color_transform(&mut self, transform: ColorTransform)
pub fn set_color_transform(&mut self, transform: ColorTransform)
Colour transform to use when decoding the image. App segments relating to colour transforms will be ignored.
sourcepub fn set_max_decoding_buffer_size(&mut self, max: usize)
pub fn set_max_decoding_buffer_size(&mut self, max: usize)
Set maximum buffer size allowed for decoded images
sourcepub fn info(&self) -> Option<ImageInfo>
pub fn info(&self) -> Option<ImageInfo>
Returns metadata about the image.
The returned value will be None
until a call to either read_info
or decode
has
returned Ok
.
sourcepub fn exif_data(&self) -> Option<&[u8]>
pub fn exif_data(&self) -> Option<&[u8]>
Returns raw exif data, starting at the TIFF header, if the image contains any.
The returned value will be None
until a call to decode
has returned Ok
.
sourcepub fn xmp_data(&self) -> Option<&[u8]>
pub fn xmp_data(&self) -> Option<&[u8]>
Returns the raw XMP packet if there is any.
The returned value will be None
until a call to decode
has returned Ok
.
sourcepub fn icc_profile(&self) -> Option<Vec<u8>>
pub fn icc_profile(&self) -> Option<Vec<u8>>
Returns the embeded icc profile if the image contains one.
sourcefn select_worker(
frame: &FrameInfo,
worker_preference: PreferWorkerKind,
) -> PreferWorkerKind
fn select_worker( frame: &FrameInfo, worker_preference: PreferWorkerKind, ) -> PreferWorkerKind
Heuristic to avoid starting thread, synchronization if we expect a small amount of parallelism to be utilized.
sourcepub fn read_info(&mut self) -> Result<(), Error>
pub fn read_info(&mut self) -> Result<(), Error>
Tries to read metadata from the image without decoding it.
If successful, the metadata can be obtained using the info
method.
sourcepub fn scale(
&mut self,
requested_width: u16,
requested_height: u16,
) -> Result<(u16, u16), Error>
pub fn scale( &mut self, requested_width: u16, requested_height: u16, ) -> Result<(u16, u16), Error>
Configure the decoder to scale the image during decoding.
This efficiently scales the image by the smallest supported scale factor that produces an image larger than or equal to the requested size in at least one axis. The currently implemented scale factors are 1/8, 1/4, 1/2 and 1.
To generate a thumbnail of an exact size, pass the desired size and then scale to the final size using a traditional resampling algorithm.
sourcepub fn decode(&mut self) -> Result<Vec<u8>, Error>
pub fn decode(&mut self) -> Result<Vec<u8>, Error>
Decodes the image and returns the decoded pixels if successful.
fn decode_internal( &mut self, stop_after_metadata: bool, worker_scope: &WorkerScope, ) -> Result<Vec<u8>, Error>
fn decode_planes( &mut self, worker: &mut dyn Worker, planes: Vec<Vec<u8>>, planes_u16: Vec<Vec<u16>>, ) -> Result<Vec<u8>, Error>
fn determine_color_transform(&self) -> ColorTransform
fn read_marker(&mut self) -> Result<Marker, Error>
fn decode_scan( &mut self, frame: &FrameInfo, scan: &ScanInfo, worker: &mut dyn Worker, finished: &[bool; 4], ) -> Result<(Option<Marker>, Option<Vec<Vec<u8>>>), Error>
Auto Trait Implementations§
impl<R> Freeze for Decoder<R>where
R: Freeze,
impl<R> RefUnwindSafe for Decoder<R>where
R: RefUnwindSafe,
impl<R> Send for Decoder<R>where
R: Send,
impl<R> Sync for Decoder<R>where
R: Sync,
impl<R> Unpin for Decoder<R>where
R: Unpin,
impl<R> UnwindSafe for Decoder<R>where
R: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more