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>

source

pub fn decode_scan_lossless( &mut self, frame: &FrameInfo, scan: &ScanInfo, ) -> Result<(Option<Marker>, Vec<Vec<u16>>), Error>

decode_scan_lossless

source§

impl<R: Read> Decoder<R>

source

pub fn new(reader: R) -> Decoder<R>

Creates a new Decoder using the reader reader.

source

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.

source

pub fn set_max_decoding_buffer_size(&mut self, max: usize)

Set maximum buffer size allowed for decoded images

source

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.

source

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.

source

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.

source

pub fn icc_profile(&self) -> Option<Vec<u8>>

Returns the embeded icc profile if the image contains one.

source

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.

source

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.

source

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.

source

pub fn decode(&mut self) -> Result<Vec<u8>, Error>

Decodes the image and returns the decoded pixels if successful.

source

fn decode_internal( &mut self, stop_after_metadata: bool, worker_scope: &WorkerScope, ) -> Result<Vec<u8>, Error>

source

fn decode_planes( &mut self, worker: &mut dyn Worker, planes: Vec<Vec<u8>>, planes_u16: Vec<Vec<u16>>, ) -> Result<Vec<u8>, Error>

source

fn determine_color_transform(&self) -> ColorTransform

source

fn read_marker(&mut self) -> Result<Marker, Error>

source

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> 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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

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

§

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>,

§

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.