Struct openexr::deep::composite_deep_scan_line::CompositeDeepScanLine [−][src]
pub struct CompositeDeepScanLine<'a, 'p> { /* fields omitted */ }
Expand description
Allows to composite multiple deep parts/files together into a single frame_buffer
use openexr::prelude::*;
use openexr::deep::{CompositeDeepScanLine, DeepScanLineInputFile};
// Open the two input deeps we want to composite
let file_a = DeepScanLineInputFile::new("a.exr", 4)?;
let data_window_a = *file_a.header().data_window::<[i32; 4]>();
let file_b = DeepScanLineInputFile::new("b.exr", 4)?;
let data_window_b = *file_b.header().data_window::<[i32; 4]>();
// Get the union of their data windows
let data_window = [
data_window_a[0].min(data_window_b[0]),
data_window_a[1].min(data_window_b[1]),
data_window_a[2].max(data_window_b[2]),
data_window_a[3].max(data_window_b[3]),
];
// Create a frame buffer to hold the composited image
let mut frame_buffer = FrameBuffer::new();
frame_buffer.insert_frame(Frame::new::<Rgba, _, _>(
&["R", "G", "B", "A"],
data_window,
)?)?;
frame_buffer.insert_frame(Frame::new::<f32, _, _>(&["Z"], data_window)?)?;
// Create the CompositeDeepScanLine, add the files, set the output
// frame buffer and read the pixels to perform the compositing.
let mut cds = CompositeDeepScanLine::new();
cds.add_source_file(&file_a)?;
cds.add_source_file(&file_b)?;
cds.set_frame_buffer(&frame_buffer);
// If this call completes successfully, `frame_buffer` will hold the
// composited R, G, B, A channels.
cds.read_pixels(data_window[1], data_window[3])?;
Implementations
Creates a Default CompositeDeepScanLine
pub fn add_source_part(
&mut self,
part: &'a mut DeepScanLineInputPart<'p>
) -> Result<(), Error>
pub fn add_source_part(
&mut self,
part: &'a mut DeepScanLineInputPart<'p>
) -> Result<(), Error>
Add a source part
Errors
Error::InvalidArgument
- If the part is missing deep Z or alpha channels, or if the display window does not match previously added sources
Add a source file
Errors
Error::InvalidArgument
- If the file is missing deep Z or alpha channels, or if the display window does not match previously added sources
Set the frame buffer to composite into. The buffer specified must be large enough to handle the unifed data window of all sources
Retrieve the frame buffer
Read scanlines from the sources from start
to end
, compositing them
and storing them in the previously provided frame buffer
Errors
Error::OutOfRange
- If the start or end scanlines are outside of the data window.
The number of sources added
Get the data window
If multiple parts are specified, this will be the union of each of their data windows.
Trait Implementations
Returns the “default value” for a type. Read more