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>
impl<S: JxlState> JxlDecoder<S>
Sourcepub fn frame_index(&self) -> Option<&FrameIndexBox>
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.
Sourcepub fn gain_map(&self) -> Option<&GainMapBundle>
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.
Sourcepub fn take_gain_map(&mut self) -> Option<GainMapBundle>
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.
Sourcepub fn exif(&self) -> Option<&[u8]>
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.
Sourcepub fn xmp(&self) -> Option<&[u8]>
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.
Sourcepub fn rewind(self) -> JxlDecoder<Initialized>
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>
impl JxlDecoder<Initialized>
pub fn new(options: JxlDecoderOptions) -> Self
pub fn process( self, input: &mut impl JxlBitstreamInput, ) -> Result<ProcessingResult<JxlDecoder<WithImageInfo>, Self>>
Source§impl JxlDecoder<WithImageInfo>
impl JxlDecoder<WithImageInfo>
Sourcepub fn basic_info(&self) -> &JxlBasicInfo
pub fn basic_info(&self) -> &JxlBasicInfo
Obtains the image’s basic information.
Sourcepub fn embedded_color_profile(&self) -> &JxlColorProfile
pub fn embedded_color_profile(&self) -> &JxlColorProfile
Retrieves the file’s color profile.
Sourcepub fn output_color_profile(&self) -> &JxlColorProfile
pub fn output_color_profile(&self) -> &JxlColorProfile
Retrieves the current output color profile.
Sourcepub fn set_output_color_profile(
&mut self,
profile: JxlColorProfile,
) -> Result<()>
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.
Sourcepub fn current_pixel_format(&self) -> &JxlPixelFormat
pub fn current_pixel_format(&self) -> &JxlPixelFormat
Retrieves the current pixel format for output buffers.
Sourcepub fn set_pixel_format(&mut self, pixel_format: JxlPixelFormat)
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.
pub fn process( self, input: &mut impl JxlBitstreamInput, ) -> Result<ProcessingResult<JxlDecoder<WithFrameInfo>, Self>>
Sourcepub fn flush_pixels(
&mut self,
buffers: &mut [JxlOutputBuffer<'_>],
) -> Result<()>
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.
pub fn has_more_frames(&self) -> bool
Source§impl JxlDecoder<WithFrameInfo>
impl JxlDecoder<WithFrameInfo>
Sourcepub fn skip_frame(
self,
input: &mut impl JxlBitstreamInput,
) -> Result<ProcessingResult<JxlDecoder<WithImageInfo>, Self>>
pub fn skip_frame( self, input: &mut impl JxlBitstreamInput, ) -> Result<ProcessingResult<JxlDecoder<WithImageInfo>, Self>>
Skip the current frame.
pub fn frame_header(&self) -> JxlFrameHeader
Sourcepub fn num_completed_passes(&self) -> usize
pub fn num_completed_passes(&self) -> usize
Number of passes we have full data for.
Sourcepub fn flush_pixels(
&mut self,
buffers: &mut [JxlOutputBuffer<'_>],
) -> Result<()>
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.
Sourcepub fn process<In: JxlBitstreamInput>(
self,
input: &mut In,
buffers: &mut [JxlOutputBuffer<'_>],
) -> Result<ProcessingResult<JxlDecoder<WithImageInfo>, Self>>
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.