Struct libheif_rs::Image
source · pub struct Image { /* private fields */ }
Implementations§
source§impl Image
impl Image
sourcepub fn new(width: u32, height: u32, color_space: ColorSpace) -> Result<Image>
pub fn new(width: u32, height: u32, color_space: ColorSpace) -> Result<Image>
Create a new image of the specified resolution and colorspace.
Note: no memory for the actual image data is reserved yet. You have to use
Image::create_plane()
method to add image planes required by your colorspace.
sourcepub fn channel_width(&self, channel: Channel) -> Option<u32>
pub fn channel_width(&self, channel: Channel) -> Option<u32>
Get width of the given image channel in pixels.
sourcepub fn channel_height(&self, channel: Channel) -> Option<u32>
pub fn channel_height(&self, channel: Channel) -> Option<u32>
Get height of the given image channel in pixels.
sourcepub fn storage_bits_per_pixel(&self, channel: Channel) -> Option<u8>
pub fn storage_bits_per_pixel(&self, channel: Channel) -> Option<u8>
Get the number of bits per pixel in the given image channel. Returns
None
if a non-existing channel was given.
Note that the number of bits per pixel may be different for each color channel.
This function returns the number of bits used for storage of each pixel.
Especially for HDR images, this is probably not what you want. Have a look at
Image::bits_per_pixel()
instead.
sourcepub fn bits_per_pixel(&self, channel: Channel) -> Option<u8>
pub fn bits_per_pixel(&self, channel: Channel) -> Option<u8>
Get the number of bits per pixel in the given image channel. Returns
None
if a non-existing channel was given.
This function returns the number of bits used for representing
the pixel value, which might be smaller than the number of bits used
in memory. For example, in 12bit HDR images, this function returns 12
,
while still 16 bits are reserved for storage. For interleaved RGBA with
12 bit, this function also returns 12
, not 48
or 64
(Image::storage_bits_per_pixel()
returns 64
in this case).
pub fn planes(&self) -> Planes<&[u8]>
pub fn planes_mut(&mut self) -> Planes<&mut [u8]>
pub fn has_channel(&self, channel: Channel) -> bool
pub fn color_space(&self) -> Option<ColorSpace>
sourcepub fn scale(
&self,
width: u32,
height: u32,
_scaling_options: Option<ScalingOptions>
) -> Result<Image>
pub fn scale( &self, width: u32, height: u32, _scaling_options: Option<ScalingOptions> ) -> Result<Image>
Scale image by “nearest neighbor” method.
Note: Currently, _scaling_options
is not used. Pass a None
.
sourcepub fn create_plane(
&mut self,
channel: Channel,
width: u32,
height: u32,
bit_depth: u8
) -> Result<()>
pub fn create_plane( &mut self, channel: Channel, width: u32, height: u32, bit_depth: u8 ) -> Result<()>
The indicated bit_depth corresponds to the bit depth per channel. I.e. for interleaved formats like RRGGBB, the bit_depth would be, e.g., 10 bit instead of 30 bits or 3*16=48 bits. For backward compatibility, one can also specify 24bits for RGB and 32bits for RGBA, instead of the preferred 8 bits.