Struct ImageData

Source
pub struct ImageData {
    pub frame: *mut IWICBitmapSource,
}
Expand description

Represents a source of pixel that can be read, but cannot be written back to.

Fields§

§frame: *mut IWICBitmapSource

Implementations§

Source§

impl ImageData

Source

pub fn resolution(&self) -> (f64, f64)

Retrieves the sampling rate between pixels and physical world measurements.

Source

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

Retrieves the pixel width and height of the bitmap.

Source

pub fn pixel_format(&self) -> WICPixelFormatGUID

Source

pub fn pixels(&self, pixel_size: u32) -> Result<Vec<u8>, NwgError>

Copy the frame pixels into a buffer.

Parameters: pixel_size: defines the size of a pixel in bytes. In a typical RGBA image, this would be 4 (1 byte for each component). If unsure, use the pixel_format.

May return an error if the pixel data could not be read

Source

pub fn region_pixels( &self, offset: [i32; 2], size: [i32; 2], pixel_size: u32, ) -> Result<Vec<u8>, NwgError>

Copy a region of the frames pixel into a buffer.

Parameters: offset: The [x,y] offset at which the region begins size: The [width, height] size of the region pixel_size: defines the size of a pixel in bytes. In a typical RGBA image, this would be 4 (1 byte for each component). If unsure, use the pixel_format.

May return an error if the pixel data could not be read

Source

pub fn as_bitmap(&self) -> Result<Bitmap, NwgError>

Create a bitmap resource the the image data. This resource can then be used in the other NWG component. The bitmap returned is considered “owned”.

Trait Implementations§

Source§

impl Drop for ImageData

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

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>,

Source§

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>,

Source§

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.