Struct libheif_rs::Image

source ·
pub struct Image { /* private fields */ }

Implementations§

source§

impl Image

source

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.

source

pub fn width(&self) -> u32

Get the width of the main channel (Y in YCbCr, or any in RGB).

source

pub fn height(&self) -> u32

Get the height of the main channel (Y in YCbCr, or any in RGB).

source

pub fn channel_width(&self, channel: Channel) -> Option<u32>

Get width of the given image channel in pixels.

source

pub fn channel_height(&self, channel: Channel) -> Option<u32>

Get height of the given image channel in pixels.

source

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.

source

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).

source

pub fn planes(&self) -> Planes<&[u8]>

source

pub fn planes_mut(&mut self) -> Planes<&mut [u8]>

source

pub fn has_channel(&self, channel: Channel) -> bool

source

pub fn color_space(&self) -> Option<ColorSpace>

source

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.

source

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.

source

pub fn set_premultiplied_alpha(&self, is_premultiplied_alpha: bool)

source

pub fn is_premultiplied_alpha(&self) -> bool

source

pub fn color_profile_raw(&self) -> Option<ColorProfileRaw>

source

pub fn set_color_profile_raw(&mut self, profile: &ColorProfileRaw) -> Result<()>

source

pub fn color_profile_nclx(&self) -> Option<ColorProfileNCLX>

source

pub fn set_color_profile_nclx( &mut self, profile: &ColorProfileNCLX ) -> Result<()>

source

pub fn pixel_aspect_ratio(&self) -> (u32, u32)

source

pub fn set_pixel_aspect_ratio(&mut self, aspect_h: u32, aspect_v: u32)

Trait Implementations§

source§

impl Drop for Image

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl Send for Image

Auto Trait Implementations§

§

impl Freeze for Image

§

impl RefUnwindSafe for Image

§

impl !Sync for Image

§

impl Unpin for Image

§

impl UnwindSafe for Image

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.