Struct Frame

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

Represents a frame captured from a graphics capture item.

§Example

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

Implementations§

Source§

impl<'a> Frame<'a>

Source

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

Creates a new Frame.

§Arguments
  • d3d_device - The ID3D11Device used for creating the frame.
  • frame_surface - The IDirect3DSurface representing the frame’s surface.
  • frame_texture - The ID3D11Texture2D representing the frame’s texture.
  • timestamp - The TimeSpan representing the frame’s timestamp, in 100-nanosecond units.
  • context - The ID3D11DeviceContext used for copying the texture.
  • buffer - A mutable reference to the buffer for the frame data.
  • width - The width of the frame.
  • height - The height of the frame.
  • color_format - The ColorFormat of the frame.
  • title_bar_height - The height of the title bar, if applicable.
§Returns

A new Frame instance.

Source

pub const fn width(&self) -> u32

Gets the width of the frame.

§Returns

The width of the frame.

Source

pub const fn height(&self) -> u32

Gets the height of the frame.

§Returns

The height of the frame.

Source

pub const fn timestamp(&self) -> TimeSpan

Gets the timestamp of the frame.

§Returns

The timestamp of the frame.

Source

pub const fn color_format(&self) -> ColorFormat

Gets the color format of the frame.

§Returns

The color format of the frame.

Source

pub const unsafe fn as_raw_surface(&self) -> &IDirect3DSurface

Gets 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 reference to an underlying Windows API object.

Source

pub const unsafe fn as_raw_texture(&self) -> &ID3D11Texture2D

Gets the raw texture of the frame.

§Returns

The ID3D11Texture2D representing the raw texture of the frame.

§Safety

This method is unsafe because it returns a reference to an underlying Windows API object.

Source

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

Gets the frame buffer.

§Returns

A 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

A FrameBuffer containing the cropped frame data.

Source

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

Gets the frame buffer without the title bar.

§Returns

A FrameBuffer containing the frame data without the title bar.

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