summaryrefslogtreecommitdiff
path: root/vendor/exr/examples/5a_write_multiple_layers.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2024-01-08 00:21:28 +0300
committerValentin Popov <valentin@popov.link>2024-01-08 00:21:28 +0300
commit1b6a04ca5504955c571d1c97504fb45ea0befee4 (patch)
tree7579f518b23313e8a9748a88ab6173d5e030b227 /vendor/exr/examples/5a_write_multiple_layers.rs
parent5ecd8cf2cba827454317368b68571df0d13d7842 (diff)
downloadfparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.tar.xz
fparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.zip
Initial vendor packages
Signed-off-by: Valentin Popov <valentin@popov.link>
Diffstat (limited to 'vendor/exr/examples/5a_write_multiple_layers.rs')
-rw-r--r--vendor/exr/examples/5a_write_multiple_layers.rs45
1 files changed, 45 insertions, 0 deletions
diff --git a/vendor/exr/examples/5a_write_multiple_layers.rs b/vendor/exr/examples/5a_write_multiple_layers.rs
new file mode 100644
index 0000000..51e2aed
--- /dev/null
+++ b/vendor/exr/examples/5a_write_multiple_layers.rs
@@ -0,0 +1,45 @@
+
+extern crate smallvec;
+extern crate rand;
+extern crate half;
+
+
+// exr imports
+extern crate exr;
+
+/// Writes multiple layers into one exr file
+/// Note: this may not be supported by legacy software
+fn main() {
+ use exr::prelude::*;
+ let size = Vec2(512, 512);
+
+
+ let layer1 = Layer::new(
+ size,
+ LayerAttributes::named("teal rgb"),
+ Encoding::FAST_LOSSLESS,
+ SpecificChannels::rgb(|_pos| (0_f32, 0.4_f32, 0.4_f32)),
+ );
+
+ let layer2 = Layer::new(
+ size,
+ LayerAttributes::named("orange rgba"),
+ Encoding::FAST_LOSSLESS,
+ SpecificChannels::rgba(|_pos| (0.8_f32, 0.5_f32, 0.1_f32, 1.0_f32)),
+ );
+
+ // define the visible area of the canvas
+ let attributes = ImageAttributes::new(
+ // the pixel section that should be shown
+ IntegerBounds::from_dimensions(size)
+ );
+
+ let image = Image::empty(attributes)
+ .with_layer(layer1) // add an rgb layer of type `SpecificChannels<ClosureA>`
+ .with_layer(layer2); // add an rgba layer of different type, `SpecificChannels<ClosureB>`, not possible with a vector
+
+ println!("writing image...");
+ image.write().to_file("layers.exr").unwrap();
+
+ println!("created file layers.exr");
+} \ No newline at end of file