Skip to main content

MaaImageBuffer

Struct MaaImageBuffer 

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

Image buffer for storing and manipulating image data.

Supports raw BGR data and encoded formats (PNG/JPEG). Compatible with OpenCV image types.

Implementations§

Source§

impl MaaImageBuffer

Source

pub fn new() -> MaaResult<Self>

Create a new buffer.

Source

pub unsafe fn from_raw(handle: *mut MaaImageBuffer) -> Self

Create from an existing handle.

§Safety

This function assumes the handle is valid. The returned buffer will NOT take ownership of the handle (it won’t be destroyed on drop). Use this when you are borrowing a handle from the C API.

Source

pub fn from_handle(handle: *mut MaaImageBuffer) -> Option<Self>

Create from an existing handle safely (checks for null). Returns None if handle is null.

Source

pub fn as_ptr(&self) -> *mut MaaImageBuffer

Get the underlying raw handle.

Source

pub fn raw(&self) -> *mut MaaImageBuffer

Get the underlying raw handle (alias for as_ptr).

Source§

impl MaaImageBuffer

Source

pub fn is_empty(&self) -> bool

Check if the buffer is empty (contains no image data).

Source

pub fn clear(&mut self) -> MaaResult<()>

Clear the buffer, releasing any image data.

Source

pub fn width(&self) -> i32

Get the image width in pixels.

Source

pub fn height(&self) -> i32

Get the image height in pixels.

Source

pub fn channels(&self) -> i32

Get the number of color channels (e.g., 3 for RGB, 4 for RGBA).

Source

pub fn image_type(&self) -> i32

Get the OpenCV image type constant.

Source

pub fn to_vec(&self) -> Option<Vec<u8>>

Get the encoded image data as a byte vector (PNG format).

Source

pub fn raw_data(&self) -> Option<&[u8]>

Get the raw image data (BGR format, row-major).

Source

pub fn set_raw_data( &mut self, data: &[u8], width: i32, height: i32, img_type: i32, ) -> MaaResult<()>

Set the image from raw BGR data.

Source

pub fn set(&mut self, data: &[u8], width: i32, height: i32) -> MaaResult<()>

Set the image from raw BGR data (assuming 3 channels, CV_8UC3).

Source

pub fn set_encoded(&mut self, data: &[u8]) -> MaaResult<()>

Set the image from encoded data (PNG/JPEG).

Source

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

Resize the image.

  • width: Target width, 0 for auto aspect ratio.
  • height: Target height, 0 for auto aspect ratio.

Trait Implementations§

Source§

impl Debug for MaaImageBuffer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MaaImageBuffer

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Drop for MaaImageBuffer

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for MaaImageBuffer

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.