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 dropsStructs§
- Pixel
Buffer Lock Guard - A guard that provides access to locked pixel buffer memory
Enums§
- Pixel
Buffer Lock Flags - Lock options for pixel buffer access
Traits§
- CVImage
Buffer Lock Ext - Extension trait for
CVImageBufferwith lock guards Extension trait for locking pixel buffers - Pixel
Buffer Cursor Ext - Extension trait for
io::Cursorto add pixel buffer specific operations