Skip to main content

JxlDecoder

Struct JxlDecoder 

Source
pub struct JxlDecoder<State: JxlState> { /* private fields */ }
Expand description

High level API using the typestate pattern to forbid invalid usage.

Implementations§

Source§

impl<S: JxlState> JxlDecoder<S>

Source

pub fn frame_index(&self) -> Option<&FrameIndexBox>

Returns the parsed frame index box, if the file contained one.

The frame index box (jxli) is an optional part of the JXL container format that provides a seek table for animated files, listing keyframe byte offsets, timestamps, and frame counts.

Source

pub fn gain_map(&self) -> Option<&GainMapBundle>

Returns a reference to the parsed gain map bundle, if the file contained a jhgm box (ISO 21496-1 HDR gain map).

The gain map codestream is a bare JXL codestream that can be decoded with the same decoder. The ISO 21496-1 metadata blob is stored as raw bytes for the caller to parse.

Source

pub fn take_gain_map(&mut self) -> Option<GainMapBundle>

Takes the parsed gain map bundle, if the file contained a jhgm box. After calling this, gain_map() will return None.

Source

pub fn exif(&self) -> Option<&[u8]>

Returns the raw EXIF data from the Exif container box, if present.

The 4-byte TIFF header offset prefix is stripped; this returns the raw EXIF/TIFF bytes starting with the byte-order marker (II or MM). Returns None for bare codestreams or files without an Exif box.

Note: the Exif box may appear after the codestream in the container. Call this after decoding at least one frame for the most complete results.

Source

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

Takes the EXIF data, leaving None in its place.

Source

pub fn xmp(&self) -> Option<&[u8]>

Returns the raw XMP data from the xml container box, if present.

Returns None for bare codestreams or files without an xml box.

Note: the xml box may appear after the codestream in the container. Call this after decoding at least one frame for the most complete results.

Source

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

Takes the XMP data, leaving None in its place.

Source

pub fn rewind(self) -> JxlDecoder<Initialized>

Rewinds a decoder to the start of the file, allowing past frames to be displayed again.

Source§

impl JxlDecoder<Initialized>

Source

pub fn new(options: JxlDecoderOptions) -> Self

Source

pub fn process( self, input: &mut impl JxlBitstreamInput, ) -> Result<ProcessingResult<JxlDecoder<WithImageInfo>, Self>>

Source§

impl JxlDecoder<WithImageInfo>

Source

pub fn basic_info(&self) -> &JxlBasicInfo

Obtains the image’s basic information.

Source

pub fn embedded_color_profile(&self) -> &JxlColorProfile

Retrieves the file’s color profile.

Source

pub fn output_color_profile(&self) -> &JxlColorProfile

Retrieves the current output color profile.

Source

pub fn set_output_color_profile( &mut self, profile: JxlColorProfile, ) -> Result<()>

Specifies the preferred color profile to be used for outputting data. Same semantics as JxlDecoderSetOutputColorProfile.

Source

pub fn current_pixel_format(&self) -> &JxlPixelFormat

Retrieves the current pixel format for output buffers.

Source

pub fn set_pixel_format(&mut self, pixel_format: JxlPixelFormat)

Specifies pixel format for output buffers.

Setting this may also change output color profile in some cases, if the profile was not set manually before.

Source

pub fn process( self, input: &mut impl JxlBitstreamInput, ) -> Result<ProcessingResult<JxlDecoder<WithFrameInfo>, Self>>

Source

pub fn flush_pixels( &mut self, buffers: &mut [JxlOutputBuffer<'_>], ) -> Result<()>

Draws all the pixels we have data for. This is useful for i.e. previewing LF frames.

Note: see process for alignment requirements for the buffer data.

Source

pub fn has_more_frames(&self) -> bool

Source§

impl JxlDecoder<WithFrameInfo>

Source

pub fn skip_frame( self, input: &mut impl JxlBitstreamInput, ) -> Result<ProcessingResult<JxlDecoder<WithImageInfo>, Self>>

Skip the current frame.

Source

pub fn frame_header(&self) -> JxlFrameHeader

Source

pub fn num_completed_passes(&self) -> usize

Number of passes we have full data for.

Source

pub fn flush_pixels( &mut self, buffers: &mut [JxlOutputBuffer<'_>], ) -> Result<()>

Draws all the pixels we have data for.

Note: see process for alignment requirements for the buffer data.

Source

pub fn process<In: JxlBitstreamInput>( self, input: &mut In, buffers: &mut [JxlOutputBuffer<'_>], ) -> Result<ProcessingResult<JxlDecoder<WithImageInfo>, Self>>

Guarantees to populate exactly the appropriate part of the buffers. Wants one buffer for each non-ignored pixel type, i.e. color channels and each extra channel.

Note: the data in buffers should have alignment requirements that are compatible with the requested pixel format. This means that, if we are asking for 2-byte or 4-byte output (i.e. u16/f16 and f32 respectively), each row in the provided buffers must be aligned to 2 or 4 bytes respectively. If that is not the case, the library may panic.

Auto Trait Implementations§

§

impl<State> Freeze for JxlDecoder<State>

§

impl<State> !RefUnwindSafe for JxlDecoder<State>

§

impl<State> !Send for JxlDecoder<State>

§

impl<State> !Sync for JxlDecoder<State>

§

impl<State> Unpin for JxlDecoder<State>
where State: Unpin,

§

impl<State> UnsafeUnpin for JxlDecoder<State>

§

impl<State> !UnwindSafe for JxlDecoder<State>

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

Source§

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

Source§

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.