Struct exr::image::SpecificChannelsBuilder
source · pub struct SpecificChannelsBuilder<RecursiveChannels, RecursivePixel> {
channels: RecursiveChannels,
px: PhantomData<RecursivePixel>,
}
Expand description
Used to construct a SpecificChannels
.
Call with_named_channel
as many times as desired,
and then call with_pixels
to define the colors.
Fields§
§channels: RecursiveChannels
§px: PhantomData<RecursivePixel>
Implementations§
source§impl<RecursiveChannels: CheckDuplicates, RecursivePixel> SpecificChannelsBuilder<RecursiveChannels, RecursivePixel>
impl<RecursiveChannels: CheckDuplicates, RecursivePixel> SpecificChannelsBuilder<RecursiveChannels, RecursivePixel>
sourcepub fn with_channel<Sample: IntoSample>(
self,
name: impl Into<Text>,
) -> SpecificChannelsBuilder<Recursive<RecursiveChannels, ChannelDescription>, Recursive<RecursivePixel, Sample>>
pub fn with_channel<Sample: IntoSample>( self, name: impl Into<Text>, ) -> SpecificChannelsBuilder<Recursive<RecursiveChannels, ChannelDescription>, Recursive<RecursivePixel, Sample>>
Add another channel to this image. Does not add the actual pixels,
but instead only declares the presence of the channel.
Panics if the name contains unsupported characters.
Panics if a channel with the same name already exists.
Use Text::new_or_none()
to manually handle these cases.
Use with_channel_details
instead if you want to specify more options than just the name of the channel.
The generic parameter can usually be inferred from the closure in with_pixels
.
sourcepub fn with_channel_details<Sample: Into<Sample>>(
self,
channel: ChannelDescription,
) -> SpecificChannelsBuilder<Recursive<RecursiveChannels, ChannelDescription>, Recursive<RecursivePixel, Sample>>
pub fn with_channel_details<Sample: Into<Sample>>( self, channel: ChannelDescription, ) -> SpecificChannelsBuilder<Recursive<RecursiveChannels, ChannelDescription>, Recursive<RecursivePixel, Sample>>
Add another channel to this image. Does not add the actual pixels,
but instead only declares the presence of the channel.
Use with_channel
instead if you only want to specify the name of the channel.
Panics if a channel with the same name already exists.
The generic parameter can usually be inferred from the closure in with_pixels
.
sourcepub fn with_pixels<Pixels>(
self,
get_pixel: Pixels,
) -> SpecificChannels<Pixels, RecursiveChannels>
pub fn with_pixels<Pixels>( self, get_pixel: Pixels, ) -> SpecificChannels<Pixels, RecursiveChannels>
Specify the actual pixel contents of the image.
You can pass a closure that returns a color for each pixel (Fn(Vec2<usize>) -> Pixel
),
or you can pass your own image if it implements GetPixel
.
The pixel type must be a tuple with the correct number of entries, depending on the number of channels.
The tuple entries can be either f16
, f32
, u32
or Sample
.
Use with_pixel_fn
instead of this function, to get extra type safety for your pixel closure.
sourcepub fn with_pixel_fn<Pixel, Pixels>(
self,
get_pixel: Pixels,
) -> SpecificChannels<Pixels, RecursiveChannels>
pub fn with_pixel_fn<Pixel, Pixels>( self, get_pixel: Pixels, ) -> SpecificChannels<Pixels, RecursiveChannels>
Specify the contents of the image.
The pixel type must be a tuple with the correct number of entries, depending on the number of channels.
The tuple entries can be either f16
, f32
, u32
or Sample
.
Use with_pixels
instead of this function, if you want to pass an object that is not a closure.
Usually, the compiler can infer the type of the pixel (for example, f16,f32,f32
) from the closure.
If that’s not possible, you can specify the type of the channels
when declaring the channel (for example, with_named_channel::<f32>("R")
).