pub struct InputFile(/* private fields */);Implementations§
Source§impl InputFile
impl InputFile
Sourcepub fn new<P: AsRef<Path>>(
filename: P,
num_threads: i32,
) -> Result<InputFile, Error>
pub fn new<P: AsRef<Path>>( filename: P, num_threads: i32, ) -> Result<InputFile, Error>
Open the file at path filename and read the header.
§Errors
Error::Base- if the file cannot be opened
Sourcepub fn set_frame_buffer(
&mut self,
frame_buffer: &FrameBuffer,
) -> Result<(), Error>
pub fn set_frame_buffer( &mut self, frame_buffer: &FrameBuffer, ) -> Result<(), Error>
Set the current frame buffer – copies the FrameBuffer object into the InputFile object.
The current frame buffer is the destination for the pixel
data read from the file. The current frame buffer must be
set at least once before read_pixels() is called.
The current frame buffer can be changed after each call
to read_pixels().
§Errors
Error::InvalidArgument- if the sampling factors do not match or if the frame buffer does not have a sample count slice.
Sourcepub fn frame_buffer(&self) -> FrameBufferRef<'_>
pub fn frame_buffer(&self) -> FrameBufferRef<'_>
Access to the current frame buffer
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Check if all pixels in the data window are present in the input file
Sourcepub fn is_optimization_enabled(&self) -> Result<bool, Error>
pub fn is_optimization_enabled(&self) -> Result<bool, Error>
Check if SSE optimization is enabled
Call after set_frame_buffer() to query whether optimized file decoding
is available - decode times will be faster if returns true
Optimization depends on:
- The file type (only scanline data is supported),
- The framebuffer channels (RGB/RGBA mono or stereo)
- The framebuffer channel types (all channels half-float format only)
- The file channels (RGB/RGBA mono or stereo)
- The file channel types (all channel half-float format only)
- Whether SSE2 instruction support was detected at compile time
§Errors
Error::InvalidArgument- if no frame buffer has been set
Sourcepub fn read_pixels(&mut self, s1: i32, s2: i32) -> Result<(), Error>
pub fn read_pixels(&mut self, s1: i32, s2: i32) -> Result<(), Error>
Read all scanlines in the range [s1, s2] and put them in the current frame buffer.
read_pixel_sample_counts() must be called before calling this method.
§Errors
Error::InvalidArgument- if no frame buffer has been set, ifs1ors2are outside the data window, or if the sample counts have not been read yetError::Base- if any other error occurs
Sourcepub fn into_reader(self, frames: Vec<Frame>) -> Result<InputFileReader, Error>
pub fn into_reader(self, frames: Vec<Frame>) -> Result<InputFileReader, Error>
Consume this InputFile and convert it to an InputFileReader.
The InputFileReader provides a safe API for reading data from the
file into memory, by taking ownership of the memory and handling calculating
Slice offsets internally.
frames is a Vec of Frame objects, which
describe the channels to load from the image, and how they are to be
stored in memory.