Expand description
Frame buffer and pixel access
This module provides types for accessing captured frame data at the pixel level.
All buffer types now use std::io::Cursor for data access, providing standard
Read and Seek traits for maximum compatibility.
§Main Types
CVPixelBuffer- Pixel buffer containing frame dataIOSurface- IOSurface-backed buffer for zero-copy accessPixelBufferLockGuard- RAII guard for locked pixel buffer accessIOSurfaceLockGuard- RAII guard for lockedIOSurfaceaccessPixelBufferCursorExt- Extension trait for pixel-specific cursor operations
§Examples
§Basic Usage with Cursor
use std::io::{Read, Seek, SeekFrom};
use screencapturekit::output::{CVImageBufferLockExt, PixelBufferLockFlags, PixelBufferCursorExt};
if let Some(pixel_buffer) = sample.get_image_buffer() {
let guard = pixel_buffer.lock(PixelBufferLockFlags::ReadOnly)?;
// Get a standard io::Cursor
let mut cursor = guard.cursor();
// Read pixels using standard Read trait
let mut pixel = [0u8; 4];
cursor.read_exact(&mut pixel)?;
// Or use the extension trait for pixel operations
cursor.seek(SeekFrom::Start(0))?;
let pixel = cursor.read_pixel()?;
// Seek to specific coordinates
cursor.seek_to_pixel(50, 50, guard.bytes_per_row())?;
}§Direct Slice Access
use screencapturekit::output::{CVImageBufferLockExt, PixelBufferLockFlags};
if let Some(pixel_buffer) = sample.get_image_buffer() {
let guard = pixel_buffer.lock(PixelBufferLockFlags::ReadOnly)?;
// Direct slice access (no cursor overhead)
let data = guard.as_slice();
println!("Frame size: {} bytes", data.len());
// Access specific rows
if let Some(row) = guard.row(100) {
println!("Row 100 has {} bytes", row.len());
}
}Re-exports§
pub use crate::cm::CMSampleBuffer;pub use crate::cm::CMTime;pub use crate::cm::CVPixelBuffer;pub use iosurface::CVPixelBufferIOSurface;pub use iosurface::IOSurface;pub use iosurface::IOSurfaceLockGuard;pub use iosurface::IOSurfaceLockOptions;pub use pixel_buffer::CVImageBufferLockExt;pub use pixel_buffer::PixelBufferCursorExt;pub use pixel_buffer::PixelBufferLockFlags;pub use pixel_buffer::PixelBufferLockGuard;
Modules§
- iosurface
IOSurfacewrapper forScreenCaptureKit- pixel_
buffer - Pixel buffer wrapper with RAII lock guards