pub struct DecoderOptions { /* private fields */ }
Expand description

Decoder options

Not all options are respected by decoders all decoders

Implementations§

source§

impl DecoderOptions

Initializers

source

pub fn new_safe() -> DecoderOptions

Create the decoder with options setting most configurable options to be their safe counterparts

This is the same as default option as default initializes options to the safe variant.

Note, decoders running on this will be slower as it disables platform specific intrinsics

source

pub fn new_fast() -> DecoderOptions

Create the decoder with options setting the configurable options to the fast counterparts

This enables platform specific code paths and enable use of unsafe

source

pub fn new_cmd() -> DecoderOptions

Create the decoder options with the following characteristics

  • Use unsafe paths.
  • Ignore error checksuming, e.g in png we do not confirm adler and crc in this mode
  • Enable fast intrinsics paths
source§

impl DecoderOptions

Global options respected by all decoders

source

pub const fn get_max_width(&self) -> usize

Get maximum width configured for which the decoder should not try to decode images greater than this width

source

pub const fn get_max_height(&self) -> usize

Get maximum height configured for which the decoder should not try to decode images greater than this height

source

pub fn get_strict_mode(&self) -> bool

Return true whether the decoder should be in strict mode And reject most errors

source

pub const fn get_use_unsafe(&self) -> bool

Return true if the decoder should use unsafe routines where possible

source

pub fn set_max_width(self, width: usize) -> Self

Set maximum width for which the decoder should not try decoding images greater than that width

Arguments
  • width: The maximum width allowed

returns: DecoderOptions

source

pub fn set_max_height(self, height: usize) -> Self

Set maximum height for which the decoder should not try decoding images greater than that height

Arguments
  • height: The maximum height allowed

returns: DecoderOptions

source

pub fn set_use_unsafe(self, yes: bool) -> Self

Whether the routines can use unsafe platform specific intrinsics when necessary

Platform intrinsics are implemented for operations which the compiler can’t auto-vectorize, or we can do a marginably better job at it

All decoders with unsafe routines respect it.

Treat this with caution, disabling it will cause slowdowns but it’s provided for mainly for debugging use.

  • Respected by: png and jpeg(decoders with unsafe routines)
source

pub fn set_strict_mode(self, yes: bool) -> Self

Set whether the decoder should be in standards conforming/ strict mode

This reduces the error tolerance level for the decoders and invalid samples will be rejected by the decoder

Arguments
  • yes:

returns: DecoderOptions

source

pub fn set_byte_endian(self, endian: ByteEndian) -> Self

Set the byte endian for which raw samples will be stored in in case a single pixel sample spans more than a byte.

The default is usually native endian hence big endian values will be converted to little endian on little endian systems,

and little endian values will be converted to big endian on big endian systems

Arguments
  • endian: The endianness to which to set the bytes to

returns: DecoderOptions

source

pub const fn get_byte_endian(&self) -> ByteEndian

Get the byte endian for which samples that span more than one byte will be treated

source§

impl DecoderOptions

PNG specific options

source

pub const fn inflate_get_confirm_adler(&self) -> bool

Whether the inflate decoder should confirm adler checksums

source

pub fn inflate_set_confirm_adler(self, yes: bool) -> Self

Set whether the inflate decoder should confirm adler checksums

source

pub const fn inflate_get_limit(&self) -> usize

Get default inflate limit for which the decoder will not try to decompress further

source

pub fn inflate_set_limit(self, limit: usize) -> Self

Set the default inflate limit for which decompressors relying on inflate won’t surpass this limit

source

pub const fn png_get_confirm_crc(&self) -> bool

Whether the inflate decoder should confirm crc 32 checksums

source

pub fn png_set_confirm_crc(self, yes: bool) -> Self

Set whether the png decoder should confirm CRC 32 checksums

source

pub fn png_set_add_alpha_channel(self, yes: bool) -> Self

Set whether the png decoder should add an alpha channel to images where possible.

For Luma images, it converts it to Luma+Alpha

For RGB images it converts it to RGB+Alpha

source

pub const fn png_get_add_alpha_channel(&self) -> bool

Return true whether the png decoder should add an alpha channel to images where possible

source

pub fn png_set_strip_to_8bit(self, yes: bool) -> Self

Whether the png decoder should reduce 16 bit images to 8 bit images implicitly.

Equivalent to png::Transformations::STRIP_16

source

pub const fn png_get_strip_to_8bit(&self) -> bool

Return a boolean indicating whether the png decoder should reduce 16 bit images to 8 bit images implicitly

source

pub const fn png_decode_animated(&self) -> bool

Return whether zune-image should decode animated images or whether we should just decode the first frame only

source

pub const fn png_set_decode_animated(self, yes: bool) -> Self

Set whether zune-image should decode animated images or whether we should just decode the first frame only

source§

impl DecoderOptions

JPEG specific options

source

pub const fn jpeg_get_max_scans(&self) -> usize

Get maximum scans for which the jpeg decoder should not go above for progressive images

source

pub fn jpeg_set_max_scans(self, max_scans: usize) -> Self

Set maximum scans for which the jpeg decoder should not exceed when reconstructing images.

source

pub const fn jpeg_get_out_colorspace(&self) -> ColorSpace

Get expected output colorspace set by the user for which the image is expected to be reconstructed into.

This may be different from the

source

pub fn jpeg_set_out_colorspace(self, colorspace: ColorSpace) -> Self

Set expected colorspace for which the jpeg output is expected to be in

This is mainly provided as is, we do not guarantee the decoder can convert to all colorspaces and the decoder can change it internally when it sees fit.

source§

impl DecoderOptions

Intrinsics support

These routines are compiled depending on the platform they are used, if compiled for a platform it doesn’t support,(e.g avx2 on Arm), it will always return false

source

pub fn use_sse2(&self) -> bool

Use SSE 2 code paths where possible

This checks for existence of SSE2 first and returns false if it’s not present

source

pub fn use_sse3(&self) -> bool

Use SSE 3 paths where possible

This also checks for SSE3 support and returns false if it’s not present

source

pub fn use_sse41(&self) -> bool

Use SSE4 paths where possible

This also checks for sse 4.1 support and returns false if it is not present

source

pub fn use_avx(&self) -> bool

Use AVX paths where possible

This also checks for AVX support and returns false if it’s not present

source

pub fn use_avx2(&self) -> bool

Use avx2 paths where possible

This also checks for AVX2 support and returns false if it’s not present

source

pub fn use_neon(&self) -> bool

source§

impl DecoderOptions

JPEG_XL specific options

source

pub const fn jxl_decode_animated(&self) -> bool

Return whether zune-image should decode animated images or whether we should just decode the first frame only

source

pub const fn jxl_set_decode_animated(self, yes: bool) -> Self

Set whether zune-image should decode animated images or whether we should just decode the first frame only

Trait Implementations§

source§

impl Clone for DecoderOptions

source§

fn clone(&self) -> DecoderOptions

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for DecoderOptions

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for DecoderOptions

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Copy for DecoderOptions

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.