Module pixel_buffer

Module pixel_buffer 

Source
Expand description

Pixel buffer wrapper with RAII lock guards

Provides safe access to CVPixelBuffer and IOSurface with automatic locking/unlocking. The lock guard pattern ensures buffers are always properly unlocked, even in case of panics.

§Examples

use screencapturekit::prelude::*;
use screencapturekit::output::{CVImageBufferLockExt, PixelBufferLockFlags};

// Create a test pixel buffer
let buffer = screencapturekit::cm::CVPixelBuffer::create(100, 100, 0x42475241)
    .map_err(|_| SCError::internal_error("Failed to create buffer"))?;

// Lock for reading (automatically unlocks on drop)
let guard = buffer.lock(PixelBufferLockFlags::ReadOnly)?;

// Access pixel data
let width = guard.width();
let height = guard.height();
let pixels = guard.as_slice();

println!("Got {}x{} frame with {} bytes", width, height, pixels.len());

// Buffer automatically unlocked here when guard drops

Structs§

PixelBufferLockGuard
A guard that provides access to locked pixel buffer memory

Enums§

PixelBufferLockFlags
Lock options for pixel buffer access

Traits§

CVImageBufferLockExt
Extension trait for CVImageBuffer with lock guards Extension trait for locking pixel buffers
PixelBufferCursorExt
Extension trait for io::Cursor to add pixel buffer specific operations