Struct DynamicFrameOwned

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

An owned version of DynamicFrame that contains its own buffer.

Implementations§

Source§

impl DynamicFrameOwned

Source

pub fn from_static<FRAME, FMT>(frame: FRAME) -> Self
where FRAME: ImageStride<FMT> + Into<Vec<u8>>, FMT: PixelFormat,

Return a new DynamicFrameOwned from a statically typed frame. This moves the input data.

Source

pub fn from_static_ref<FMT: PixelFormat>(frame: &dyn ImageStride<FMT>) -> Self

Return a new DynamicFrameOwned from a reference to a statically typed frame. This copies the input data.

Source

pub fn from_buf( w: u32, h: u32, stride: usize, buf: Vec<u8>, pixfmt: PixFmt, ) -> Option<Self>

Creates a new DynamicFrameOwned from raw image data.

This function moves the provided buffer into the new frame without copying. The buffer size must be appropriate for the given dimensions and pixel format.

§Parameters
  • w - Image width in pixels
  • h - Image height in pixels
  • s - Row stride in bytes (must be >= width * bytes_per_pixel)
  • buf - Raw image data buffer
  • pixfmt - Pixel format of the image data
§Returns
  • Some(DynamicFrameOwned) if the buffer is valid for the given parameters
  • None if the buffer is too small.
Source

pub fn borrow(&self) -> DynamicFrame<'_>

Return a borrowed view of this frame as a DynamicFrame.

Source

pub fn roi( self, left: u32, top: u32, width: u32, height: u32, ) -> Option<DynamicFrameOwned>

Moves data into a new DynamicFrameOwned containing a region of interest (ROI) within the image without copying.

The ROI is defined by the specified left, top, width, and height parameters. If the specified ROI is out of bounds or the buffer is too small, this method returns None.

§Parameters
  • left - The left coordinate of the ROI in pixels
  • top - The top coordinate of the ROI in pixels
  • width - The width of the ROI in pixels
  • height - The height of the ROI in pixels
§Returns
  • Some(DynamicFrameOwned) if the ROI is valid and the buffer is large enough
  • None if the ROI is out of bounds or the buffer is too small

To create a view with a ROI, use [Self::borrow().roi()].

Source

pub fn as_static<FMT: PixelFormat>(self) -> Option<OImage<FMT>>

Moves the DynamicFrameOwned into a static pixel format.

Source

pub fn into_pixel_format<FMT>(self) -> Result<OImage<FMT>, Error>
where FMT: PixelFormat,

Available on crate feature convert-image only.

Converts the image to the specified pixel format, returning an OImage that owns the data.

If the requested pixel format matches the current format, this method moves the data without copying. Otherwise, the data is converted and a new owned image is returned. In both cases, the original image data is consumed.

§Type Parameters
  • FMT - The target pixel format type
§Returns
  • Ok(OImage<FMT>) - If conversion is successful, returns an owned image in the specified format
  • Err(convert_image::Error) - If conversion fails
§Examples
let data = vec![64u8; 2000];
let frame = DynamicFrameOwned::from_buf(40, 50, 40, data, PixFmt::Mono8).unwrap();

// No conversion or copying needed - returns original data
let owned_image = frame.into_pixel_format::<Mono8>().unwrap();

Trait Implementations§

Source§

impl Clone for DynamicFrameOwned

Source§

fn clone(&self) -> DynamicFrameOwned

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for DynamicFrameOwned

Source§

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

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

impl Stride for DynamicFrameOwned

Source§

fn stride(&self) -> usize

the width (in bytes) of each row of image data 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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.