aboutsummaryrefslogtreecommitdiff
path: root/vendor/exr/examples/1a_write_rgba_with_metadata.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2024-07-19 15:37:58 +0300
committerValentin Popov <valentin@popov.link>2024-07-19 15:37:58 +0300
commita990de90fe41456a23e58bd087d2f107d321f3a1 (patch)
tree15afc392522a9e85dc3332235e311b7d39352ea9 /vendor/exr/examples/1a_write_rgba_with_metadata.rs
parent3d48cd3f81164bbfc1a755dc1d4a9a02f98c8ddd (diff)
downloadfparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.tar.xz
fparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.zip
Deleted vendor folder
Diffstat (limited to 'vendor/exr/examples/1a_write_rgba_with_metadata.rs')
-rw-r--r--vendor/exr/examples/1a_write_rgba_with_metadata.rs64
1 files changed, 0 insertions, 64 deletions
diff --git a/vendor/exr/examples/1a_write_rgba_with_metadata.rs b/vendor/exr/examples/1a_write_rgba_with_metadata.rs
deleted file mode 100644
index 394410f..0000000
--- a/vendor/exr/examples/1a_write_rgba_with_metadata.rs
+++ /dev/null
@@ -1,64 +0,0 @@
-
-// exr imports
-extern crate exr;
-
-/// Write an rgba exr file, generating the pixel values on the fly.
-/// This streams the generated pixel directly to the file,
-/// never allocating the actual total pixel memory of the image.
-fn main() {
- use exr::prelude::*;
- use exr::meta::attribute::*;
-
- // this function can generate a color for any pixel
- let generate_pixels = |position: Vec2<usize>| (
- position.x() as f32 / 2048.0, // red
- position.y() as f32 / 2048.0, // green
- 1.0 - (position.y() as f32 / 2048.0), // blue
- 1.0 // alpha
- );
-
- let mut layer_attributes = LayerAttributes::named("generated rgba main layer");
- layer_attributes.comments = Some(Text::from("This image was generated as part of an example"));
- layer_attributes.owner = Some(Text::from("The holy lambda function"));
- layer_attributes.software_name = Some(Text::from("EXRS Project"));
- layer_attributes.exposure = Some(1.0);
- layer_attributes.focus = Some(12.4);
- layer_attributes.frames_per_second = Some((60, 1));
- layer_attributes.other.insert(
- Text::from("Layer Purpose (Custom Layer Attribute)"),
- AttributeValue::Text(Text::from("This layer contains the rgb pixel data"))
- );
-
- let layer = Layer::new(
- (2*2048, 2*2048),
- layer_attributes,
- Encoding::SMALL_FAST_LOSSLESS, // use fast but lossy compression
-
- SpecificChannels::rgba(generate_pixels)
- );
-
- // crop away black and transparent pixels from the border, if any
- let layer = layer
- .crop_where_eq((0.0, 0.0, 0.0, 0.0))
- .or_crop_to_1x1_if_empty();
-
- let mut image = Image::from_layer(layer);
- image.attributes.pixel_aspect = 1.0;
-
- image.attributes.time_code = Some(TimeCode {
- hours: 0,
- minutes: 1,
- seconds: 59,
- frame: 29,
- ..TimeCode::default()
- });
-
- image.attributes.other.insert(
- Text::from("Mice Count (Custom Image Attribute)"),
- AttributeValue::I32(23333)
- );
-
- // write it to a file with all cores in parallel
- image.write().to_file("generated_rgba_with_meta.exr").unwrap();
- println!("created file generated_rgba_with_meta.exr");
-} \ No newline at end of file