Debian Codegraph @

examples/4a_write_custom_fixed_channels.rs

raw symbols SCIP
1
2 // exr imports
3 extern crate exrrust-analyzer cargo exr 1.74.0 exr/;
4
5 /// Create an image with strange channels and write it to a file.
6 fn mainrust-analyzer cargo exr 1.74.0 main().() {
7 use exrrust-analyzer cargo exr 1.74.0 crate/::preluderust-analyzer cargo exr 1.74.0 prelude/::*;
8
9 let pixels = SpecificChannelsrust-analyzer cargo exr 1.74.0 image/SpecificChannels#::buildrust-analyzer cargo exr 1.74.0 image/impl#[`SpecificChannels<(), ()>`]build().()
10 .with_channelrust-analyzer cargo exr 1.74.0 image/impl#[`SpecificChannelsBuilder<RecursiveChannels, RecursivePixel>`]with_channel().("Kharthanasus Korthus")
11 .with_channelrust-analyzer cargo exr 1.74.0 image/impl#[`SpecificChannelsBuilder<RecursiveChannels, RecursivePixel>`]with_channel().("Y")
12 .with_channelrust-analyzer cargo exr 1.74.0 image/impl#[`SpecificChannelsBuilder<RecursiveChannels, RecursivePixel>`]with_channel().("11023")
13 .with_channelrust-analyzer cargo exr 1.74.0 image/impl#[`SpecificChannelsBuilder<RecursiveChannels, RecursivePixel>`]with_channel().("*?!")
14 .with_channelrust-analyzer cargo exr 1.74.0 image/impl#[`SpecificChannelsBuilder<RecursiveChannels, RecursivePixel>`]with_channel().("`--\"")
15 .with_channelrust-analyzer cargo exr 1.74.0 image/impl#[`SpecificChannelsBuilder<RecursiveChannels, RecursivePixel>`]with_channel().("\r\r\r\n\n")
16 .with_pixel_fnrust-analyzer cargo exr 1.74.0 image/impl#[`SpecificChannelsBuilder<RecursiveChannels, RecursivePixel>`]with_pixel_fn().(|position|{
17 if position.0rust-analyzer cargo exr 1.74.0 math/Vec2#0. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().1000 {
18 (f16rust-analyzer cargo half 2.6.0 binary16/f16#::from_f32rust-analyzer cargo half 2.6.0 binary16/impl#[f16]from_f32().(0.2), 0.666_f32, 4_u32, 1532434.0213_f32, 0.99999_f32, 3.142594_f32/rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div().4.0)
19 }
20 else {
21 (f16rust-analyzer cargo half 2.6.0 binary16/f16#::from_f32rust-analyzer cargo half 2.6.0 binary16/impl#[f16]from_f32().(0.4), 0.777_f32, 8_u32, 102154.3_f32, 0.00001_f32, 3.142594_f32/rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div().4.0)
22 }
23 });
24
25 let image = Imagerust-analyzer cargo exr 1.74.0 image/Image#::from_channelsrust-analyzer cargo exr 1.74.0 image/impl#[`Image<Layer<ChannelData>>`]from_channels().((2000, 1400), pixels);
26
27 // print progress only if it advances more than 1%
28 let mut current_progress_percentage = 0;
29
30 image.writerust-analyzer cargo exr 1.74.0 image/write/impl#[`&'img Image<WritableLayers>`][`WritableImage<'img, WritableLayers>`]write().()
31 .on_progressrust-analyzer cargo exr 1.74.0 image/write/impl#[`WriteImageWithOptions<'img, L, F>`]on_progress().(|progress| {
32 let new_progress = (progress rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().100.0) as usize;
33 if new_progress rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().current_progress_percentage {
34 current_progress_percentage = new_progress;
35 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("progress: {}%", current_progress_percentage)
36 }
37 })
38 .to_filerust-analyzer cargo exr 1.74.0 image/write/impl#[`WriteImageWithOptions<'img, L, F>`]to_file().("custom_channels.exr").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
39
40 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("created file custom_channels.exr");
41 }