Struct FrameBuffer

Source
pub struct FrameBuffer<'a> { /* private fields */ }
Expand description

Represents a frame buffer containing pixel data.

ยงExample

โ“˜
// Get frame from the capture session
let mut buffer = frame.buffer()?;
buffer.save_as_image("screenshot.png", ImageFormat::Png)?;

Implementationsยง

Sourceยง

impl<'a> FrameBuffer<'a>

Source

pub fn new( raw_buffer: &'a mut [u8], buffer: &'a mut Vec<u8>, width: u32, height: u32, row_pitch: u32, depth_pitch: u32, color_format: ColorFormat, ) -> Self

Create a new Frame Buffer.

ยงArguments
  • raw_buffer - A mutable reference to the raw pixel data buffer.
  • buffer - A mutable reference to the buffer used for copying pixel data without padding.
  • width - The width of the frame buffer.
  • height - The height of the frame buffer.
  • row_pitch - The row pitch of the frame buffer.
  • depth_pitch - The depth pitch of the frame buffer.
  • color_format - The color format of the frame buffer.
ยงReturns

A new FrameBuffer instance.

Source

pub const fn width(&self) -> u32

Get the width of the frame buffer.

Source

pub const fn height(&self) -> u32

Get the height of the frame buffer.

Source

pub const fn row_pitch(&self) -> u32

Get the row pitch of the frame buffer.

Source

pub const fn depth_pitch(&self) -> u32

Get the depth pitch of the frame buffer.

Source

pub const fn has_padding(&self) -> bool

Check if the buffer has padding.

Source

pub fn as_raw_buffer(&mut self) -> &mut [u8] โ“˜

Get the raw pixel data with possible padding.

Source

pub fn as_nopadding_buffer(&mut self) -> Result<&mut [u8], Error>

Get the raw pixel data without padding.

ยงReturns

A mutable reference to the buffer containing pixel data without padding.

Source

pub fn save_as_image<T: AsRef<Path>>( &mut self, path: T, format: ImageFormat, ) -> Result<(), Error>

Save the frame buffer as an image to the specified path.

ยงArguments
  • path - The path where the image will be saved.
  • format - The image format to use for saving.
ยงReturns

An Ok result if the image is successfully saved, or an Err result if there was an error.

Auto Trait Implementationsยง

ยง

impl<'a> Freeze for FrameBuffer<'a>

ยง

impl<'a> RefUnwindSafe for FrameBuffer<'a>

ยง

impl<'a> Send for FrameBuffer<'a>

ยง

impl<'a> Sync for FrameBuffer<'a>

ยง

impl<'a> Unpin for FrameBuffer<'a>

ยง

impl<'a> !UnwindSafe for FrameBuffer<'a>

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> 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> Pointable for T

Sourceยง

const ALIGN: usize

The alignment of pointer.
Sourceยง

type Init = T

The type for initializers.
Sourceยง

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Sourceยง

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Sourceยง

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Sourceยง

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.