extern crate exr;
fn main() {
use exr::prelude::*;
let image = read().no_deep_data()
.largest_resolution_level()
.specific_channels()
.optional("A", f16::ONE)
.required("Y") .optional("right.Y", 0.0)
.collect_pixels(
|resolution, (a_channel, y_channel, y_right_channel)| {
println!("image contains alpha channel? {}", a_channel.is_some());
println!("image contains stereoscopic luma channel? {}", y_right_channel.is_some());
println!("the type of luma samples is {:?}", y_channel.sample_type);
vec![vec![(f16::ZERO, 0.0, 0.0); resolution.width()]; resolution.height()]
},
|vec, position, (a,y,yr): (f16, f32, f32)| {
vec[position.y()][position.x()] = (a, y, yr)
}
)
.all_layers()
.all_attributes()
.on_progress(|progress| println!("progress: {:.1}", progress*100.0))
.from_file("tests/images/valid/openexr/MultiView/Fog.exr")
.unwrap();
for layer in &image.layer_data {
let (alpha, luma, luma_right) = layer.channel_data.pixels.first().unwrap().first().unwrap();
println!(
"bottom left color of layer `{}`: (a, y, yr) = {:?}",
layer.attributes.layer_name.clone().unwrap_or_default(),
(alpha.to_f32(), luma, luma_right)
)
}
}