Struct jpegxl_rs::decode::JxlDecoder

source ·
pub struct JxlDecoder<'pr, 'mm> {
    pub pixel_format: Option<PixelFormat>,
    pub skip_reorientation: Option<bool>,
    pub unpremul_alpha: Option<bool>,
    pub render_spotcolors: Option<bool>,
    pub coalescing: Option<bool>,
    pub desired_intensity_target: Option<f32>,
    pub decompress: Option<bool>,
    pub progressive_detail: Option<JxlProgressiveDetail>,
    pub icc_profile: bool,
    pub init_jpeg_buffer: usize,
    pub parallel_runner: Option<&'pr dyn JxlParallelRunner>,
    pub memory_manager: Option<&'mm dyn MemoryManager>,
    /* private fields */
}
Expand description

JPEG XL Decoder

Fields§

§pixel_format: Option<PixelFormat>

Override desired pixel format

§skip_reorientation: Option<bool>

Enables or disables preserving of as-in-bitstream pixel data orientation. If it is set to true, the decoder will skip applying the transformation

§Default

false, and the returned pixel data is re-oriented

§unpremul_alpha: Option<bool>

Enables or disables preserving of associated alpha channels. If it is set to true, the colors will be unpremultiplied based on the alpha channel

§Default

false, and return the pixel data “as is”.

§render_spotcolors: Option<bool>

Enables or disables rendering spot colors. If it is set to false, then spot colors are not rendered, and have to be retrieved separately. This is useful for printing applications

§Default

true, and spot colors are rendered, which is OK for viewing the decoded image

§coalescing: Option<bool>

Enables or disables coalescing of zero-duration frames. For loading a multi-layer still image as separate layers (as opposed to the merged image), coalescing has to be disabled

§Default

true, and all frames have the image dimensions, and are blended if needed.

§desired_intensity_target: Option<f32>

Perform tone mapping to the peak display luminance.

§Note

This is provided for convenience and the exact tone mapping that is performed is not meant to be considered authoritative in any way. It may change from version to version

§decompress: Option<bool>

Configures whether to get boxes in raw mode or in decompressed mode.

§Default

false, and the boxes are returned in raw mode

§progressive_detail: Option<JxlProgressiveDetail>

Configures at which progressive steps in frame decoding

§Default

ProgressiveDetail::DC

§icc_profile: bool

Set if need ICC profile

§Default

false

§init_jpeg_buffer: usize

Set initial buffer for JPEG reconstruction Larger buffer could make reconstruction faster by doing fewer reallocations

Default: 512 KiB

§parallel_runner: Option<&'pr dyn JxlParallelRunner>

Set parallel runner

§memory_manager: Option<&'mm dyn MemoryManager>

Set memory manager

Implementations§

source§

impl<'pr, 'mm> JxlDecoder<'pr, 'mm>

source

pub fn decode(&self, data: &[u8]) -> Result<(Metadata, Pixels), DecodeError>

Decode a JPEG XL image

§Errors

Return a DecodeError when internal decoder fails

source

pub fn decode_with<T: PixelType>( &self, data: &[u8] ) -> Result<(Metadata, Vec<T>), DecodeError>

Decode a JPEG XL image to a specific pixel type

§Errors

Return a DecodeError when internal decoder fails

source

pub fn reconstruct(&self, data: &[u8]) -> Result<(Metadata, Data), DecodeError>

Reconstruct JPEG data. Fallback to pixels if JPEG reconstruction fails

§Note

You can reconstruct JPEG data or get pixels in one go

§Errors

Return a DecodeError when internal decoder fails

Trait Implementations§

source§

impl<'prl, 'mm> Drop for JxlDecoder<'prl, 'mm>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<'pr, 'mm> ToDynamic for JxlDecoder<'pr, 'mm>

Available on crate feature image only.
source§

fn decode_to_image( &self, data: &[u8] ) -> Result<Option<DynamicImage>, DecodeError>

Decode the JPEG XL image to a DynamicImage Read more
source§

fn decode_to_image_with<T: PixelType>( &self, data: &[u8] ) -> Result<Option<DynamicImage>, DecodeError>

Decode the JPEG XL image to a DynamicImage with a specific pixel type Read more

Auto Trait Implementations§

§

impl<'pr, 'mm> Freeze for JxlDecoder<'pr, 'mm>

§

impl<'pr, 'mm> !RefUnwindSafe for JxlDecoder<'pr, 'mm>

§

impl<'pr, 'mm> !Send for JxlDecoder<'pr, 'mm>

§

impl<'pr, 'mm> !Sync for JxlDecoder<'pr, 'mm>

§

impl<'pr, 'mm> Unpin for JxlDecoder<'pr, 'mm>

§

impl<'pr, 'mm> !UnwindSafe for JxlDecoder<'pr, 'mm>

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

§

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.