pub struct DynamicFrameOwned { /* private fields */ }Expand description
An owned version of DynamicFrame that contains its own buffer.
Implementations§
Source§impl DynamicFrameOwned
impl DynamicFrameOwned
Sourcepub fn from_static<FRAME, FMT>(frame: FRAME) -> Self
pub fn from_static<FRAME, FMT>(frame: FRAME) -> Self
Return a new DynamicFrameOwned from a statically typed frame. This
moves the input data.
Sourcepub fn from_static_ref<FMT: PixelFormat>(frame: &dyn ImageStride<FMT>) -> Self
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.
Sourcepub fn from_buf(
w: u32,
h: u32,
stride: usize,
buf: Vec<u8>,
pixfmt: PixFmt,
) -> Option<Self>
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 pixelsh- Image height in pixelss- Row stride in bytes (must be >= width *bytes_per_pixel)buf- Raw image data bufferpixfmt- Pixel format of the image data
§Returns
Some(DynamicFrameOwned)if the buffer is valid for the given parametersNoneif the buffer is too small.
Sourcepub fn borrow(&self) -> DynamicFrame<'_>
pub fn borrow(&self) -> DynamicFrame<'_>
Return a borrowed view of this frame as a DynamicFrame.
Sourcepub fn roi(
self,
left: u32,
top: u32,
width: u32,
height: u32,
) -> Option<DynamicFrameOwned>
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 pixelstop- The top coordinate of the ROI in pixelswidth- The width of the ROI in pixelsheight- The height of the ROI in pixels
§Returns
Some(DynamicFrameOwned)if the ROI is valid and the buffer is large enoughNoneif the ROI is out of bounds or the buffer is too small
To create a view with a ROI, use [Self::borrow().roi()].
Sourcepub fn as_static<FMT: PixelFormat>(self) -> Option<OImage<FMT>>
pub fn as_static<FMT: PixelFormat>(self) -> Option<OImage<FMT>>
Moves the DynamicFrameOwned into a static pixel format.
Sourcepub fn into_pixel_format<FMT>(self) -> Result<OImage<FMT>, Error>where
FMT: PixelFormat,
Available on crate feature convert-image only.
pub fn into_pixel_format<FMT>(self) -> Result<OImage<FMT>, Error>where
FMT: PixelFormat,
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 formatErr(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
impl Clone for DynamicFrameOwned
Source§fn clone(&self) -> DynamicFrameOwned
fn clone(&self) -> DynamicFrameOwned
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DynamicFrameOwned
impl Debug for DynamicFrameOwned
Auto Trait Implementations§
impl Freeze for DynamicFrameOwned
impl RefUnwindSafe for DynamicFrameOwned
impl Send for DynamicFrameOwned
impl Sync for DynamicFrameOwned
impl Unpin for DynamicFrameOwned
impl UnwindSafe for DynamicFrameOwned
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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