[−][src]Struct openexr::output::ScanlineOutputFile
Writes scanline OpenEXR files.
This is the simplest kind of OpenEXR file. Image data is stored in scanline order with no special features like mipmaps or deep image data. Unless you need special features like that, this is probably what you want to use.
Examples
Write a floating point RGB image to a file named "output_file.exr".
// Create file with the desired resolution and channels. let mut file = std::fs::File::create("output_file.exr").unwrap(); let mut output_file = ScanlineOutputFile::new( &mut file, Header::new() .set_resolution(256, 256) .add_channel("R", PixelType::FLOAT) .add_channel("G", PixelType::FLOAT) .add_channel("B", PixelType::FLOAT)) .unwrap(); // Create the image data and write it to the file. let pixel_data = vec![(0.5f32, 1.0f32, 0.5f32); 256 * 256]; let mut fb = FrameBuffer::new(256, 256); fb.insert_channels(&["R", "G", "B"], &pixel_data); output_file.write_pixels(&fb).unwrap();
Methods
impl<'a> ScanlineOutputFile<'a>
[src]
pub fn new<T: 'a>(
writer: &'a mut T,
header: &Header
) -> Result<ScanlineOutputFile<'a>> where
T: Write + Seek,
[src]
writer: &'a mut T,
header: &Header
) -> Result<ScanlineOutputFile<'a>> where
T: Write + Seek,
Creates a new ScanlineOutputFile
from any Write + Seek
type
(typically a std::fs::File
) and header
.
Note: this seeks to byte 0 before writing.
pub fn write_pixels(&mut self, framebuffer: &FrameBuffer) -> Result<()>
[src]
Writes the entire image at once from framebuffer
.
Errors
This function expects framebuffer
to have the same resolution as the
output file, as well as the same channels (with matching types and
subsampling).
It will also return an error if:
- Part or all of the image data has already been written by a previous
call to either this or
write_pixels_incremental
. - There is an I/O error.
pub fn write_pixels_incremental(
&mut self,
framebuffer: &FrameBuffer
) -> Result<()>
[src]
&mut self,
framebuffer: &FrameBuffer
) -> Result<()>
Writes the image incrementally over multiple calls.
framebuffer
may have a different vertical resolution than the image,
but it must have the same horizontal resolution. Multiple calls will
incrementally write chunks of scanlines in the order given until the
image is complete.
For example, to write a 2000-pixel-tall image, you could call this function four times with 500-pixel-tall FrameBuffers.
Note: all scanlines must be written for the resulting OpenEXR file to be complete and correct.
Errors
This function expects framebuffer
to have the same horizontal
resolution as the output file, as well as the same channels (with
matching types and subsampling).
It will also return an error if:
framebuffer
contains more scanlines than remain to be written.- There is an I/O error.
pub fn header(&self) -> &Header
[src]
Access to the file's header.
Trait Implementations
impl<'a> Drop for ScanlineOutputFile<'a>
[src]
Auto Trait Implementations
impl<'a> !Send for ScanlineOutputFile<'a>
impl<'a> !Sync for ScanlineOutputFile<'a>
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,