diff options
author | Valentin Popov <valentin@popov.link> | 2024-01-08 00:21:28 +0300 |
---|---|---|
committer | Valentin Popov <valentin@popov.link> | 2024-01-08 00:21:28 +0300 |
commit | 1b6a04ca5504955c571d1c97504fb45ea0befee4 (patch) | |
tree | 7579f518b23313e8a9748a88ab6173d5e030b227 /vendor/exr/examples/0a_write_rgba.rs | |
parent | 5ecd8cf2cba827454317368b68571df0d13d7842 (diff) | |
download | fparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.tar.xz fparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.zip |
Initial vendor packages
Signed-off-by: Valentin Popov <valentin@popov.link>
Diffstat (limited to 'vendor/exr/examples/0a_write_rgba.rs')
-rw-r--r-- | vendor/exr/examples/0a_write_rgba.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/vendor/exr/examples/0a_write_rgba.rs b/vendor/exr/examples/0a_write_rgba.rs new file mode 100644 index 0000000..daa4fcd --- /dev/null +++ b/vendor/exr/examples/0a_write_rgba.rs @@ -0,0 +1,36 @@ +extern crate exr; + + +/// `exr` offers a few simplified functions for the most basic use cases. +/// `write_rgb_f32_file` is a such a function, which writes a plain rgba exr file. +/// +/// To write your image data, you need to specify how to retrieve a single pixel from it. +/// The closure may capture variables or generate data on the fly. +fn main() { + use exr::prelude::*; + + // write a file, with 32-bit float precision per channel + write_rgba_file( + + // this accepts paths or &str + "minimal_rgba.exr", + + // image resolution is 2k + 2048, 2048, + + // generate (or lookup in your own image) + // an f32 rgb color for each of the 2048x2048 pixels + // (you could also create f16 values here to save disk space) + |x,y| { + ( + x as f32 / 2048.0, // red + y as f32 / 2048.0, // green + 1.0 - (y as f32 / 2048.0), // blue + 1.0 // alpha + ) + } + + ).unwrap(); + + println!("created file minimal_rgb.exr"); +}
\ No newline at end of file |