Struct windows_capture::frame::Frame

source ยท
pub struct Frame<'a> { /* private fields */ }
Expand description

Represents a frame captured from a graphics capture item.

ยงExample

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

Implementationsยง

sourceยง

impl<'a> Frame<'a>

source

pub fn new( d3d_device: &'a ID3D11Device, frame_surface: IDirect3DSurface, frame_texture: ID3D11Texture2D, time: TimeSpan, context: &'a ID3D11DeviceContext, buffer: &'a mut Vec<u8>, width: u32, height: u32, color_format: ColorFormat ) -> Self

Create a new Frame.

ยงArguments
  • d3d_device - The ID3D11Device used for creating the frame.
  • frame_surface - The IDirect3DSurface representing the frame surface.
  • frame_texture - The ID3D11Texture2D representing the frame texture.
  • time - The TimeSpan representing the frame time.
  • context - The ID3D11DeviceContext used for copying the texture.
  • buffer - The mutable Vec representing the frame buffer.
  • width - The width of the frame.
  • height - The height of the frame.
  • color_format - The ColorFormat of the frame.
ยงReturns

A new Frame instance.

source

pub const fn width(&self) -> u32

Get the width of the frame.

ยงReturns

The width of the frame.

source

pub const fn height(&self) -> u32

Get the height of the frame.

ยงReturns

The height of the frame.

source

pub const fn timespan(&self) -> TimeSpan

Get the time of the frame.

ยงReturns

The time of the frame.

source

pub unsafe fn as_raw_surface(&self) -> IDirect3DSurface

Get the raw surface of the frame.

ยงReturns

The IDirect3DSurface representing the raw surface of the frame.

ยงSafety

This method is unsafe because it returns a raw pointer to the IDirect3DSurface.

source

pub fn buffer(&mut self) -> Result<FrameBuffer<'_>, Error>

Get the frame buffer.

ยงReturns

The FrameBuffer containing the frame data.

source

pub fn buffer_crop( &mut self, start_width: u32, start_height: u32, end_width: u32, end_height: u32 ) -> Result<FrameBuffer<'_>, Error>

Get a cropped frame buffer.

ยงArguments
  • start_width - The starting width of the cropped frame.
  • start_height - The starting height of the cropped frame.
  • end_width - The ending width of the cropped frame.
  • end_height - The ending height of the cropped frame.
ยงReturns

The FrameBuffer containing the cropped frame data.

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 ImageFormat of the saved image.
ยงReturns

An empty Result if successful, or an Error if there was an issue saving the image.

Auto Trait Implementationsยง

ยง

impl<'a> Freeze for Frame<'a>

ยง

impl<'a> RefUnwindSafe for Frame<'a>

ยง

impl<'a> !Send for Frame<'a>

ยง

impl<'a> !Sync for Frame<'a>

ยง

impl<'a> Unpin for Frame<'a>

ยง

impl<'a> !UnwindSafe for Frame<'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.
ยง

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>,

ยง

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>,

ยง

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.