Struct InputFile

Source
pub struct InputFile(/* private fields */);

Implementations§

Source§

impl InputFile

Source

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
Source

pub fn header(&self) -> HeaderRef<'_>

Access to the file Header

Source

pub fn version(&self) -> i32

Access to the file format version

Source

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.
Source

pub fn frame_buffer(&self) -> FrameBufferRef<'_>

Access to the current frame buffer

Source

pub fn is_complete(&self) -> bool

Check if all pixels in the data window are present in the input file

Source

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
Source

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, if s1 or s2 are outside the data window, or if the sample counts have not been read yet
  • Error::Base - if any other error occurs
Source

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.

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