Struct UnimageProcessor

Source
pub struct UnimageProcessor { /* private fields */ }
Expand description

A image processor. it can load image, resize it or clip it.

Implementations§

Source§

impl UnimageProcessor

Source

pub fn new() -> UnimageProcessor

Create a UnimageProcessor instance.

Source

pub unsafe fn get_instance(&self) -> *mut c_void

Get the instance pointer

Source

pub fn load_raw( &mut self, data: *mut u8, width: i32, height: i32, format: UnimageFormat, )

Load pixels from a pointer.

Source

pub fn load_raw_from_vec( &mut self, data: &mut Vec<u8>, width: i32, height: i32, format: UnimageFormat, )

Load pixels from a Vec<u8>.

Source

pub fn load_raw_from_slice( &mut self, data: &mut [u8], width: i32, height: i32, format: UnimageFormat, )

Load pixels from a Slice.

Source

pub fn load(&mut self, data: *mut u8, len: u32) -> Result<(), UnimageError>

Load an image from data, if there is something wrong, it will return an error.

Source

pub fn load_from_vec(&mut self, data: &mut Vec<u8>) -> Result<(), UnimageError>

Load an image from data, if there is something wrong, it will return an error.

Source

pub fn load_from_slice(&mut self, data: &mut [u8]) -> Result<(), UnimageError>

Load an image from data, if there is something wrong, it will return an error.

Source

pub fn get_width(&self) -> i32

Get the width of image.

Source

pub fn get_height(&self) -> i32

Get the height of image.

Source

pub fn get_format(&self) -> UnimageFormat

Get the pixel format of image.

Source

pub fn get_error_message(&self) -> String

Get the last error message.

Source

pub fn resize(&mut self, width: i32, height: i32) -> Result<(), UnimageError>

Resize the image.

Source

pub unsafe fn get_buffer_as_mut(&mut self) -> *mut u8

Get the buffer of processor, it will return a pointer that points to pixels data. If it doesn’t load any image, it will return a nullptr.

Source

pub unsafe fn get_buffer(&self) -> *const u8

Get the buffer of processor, it will return a pointer that points to pixels data. If it doesn’t load any image, it will return a nullptr.

Source

pub fn try_clone(&self) -> Result<Self, UnimageError>

Clone the processor instance and the image buffer in it. If there is something wrong, it will return a error.

Source

pub fn clip( &mut self, x: i32, y: i32, width: i32, height: i32, ) -> Result<(), UnimageError>

Clip the image.

Trait Implementations§

Source§

impl Clone for UnimageProcessor

Source§

fn clone(&self) -> Self

Clone the processor instance and the image buffer in it.

1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Drop for UnimageProcessor

Source§

fn drop(&mut self)

Release the processor instance and the buffer in it.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.