#[non_exhaustive]pub enum PixelFormat {
BGRA,
l10r,
YCbCr_420v,
YCbCr_420f,
xf44,
RGhA,
Unknown(FourCharCode),
}Expand description
Pixel format for captured video frames
Specifies the layout and encoding of pixel data in captured frames.
This enum is #[non_exhaustive]. Apple may add new pixel formats in
future macOS releases; downstream code that exhaustively matches on
PixelFormat must include a wildcard arm. Pixel formats this crate
does not yet recognise are surfaced via the PixelFormat::Unknown
variant rather than being silently coerced to PixelFormat::BGRA
(which would mislead callers that branch on the format).
§Equality and hashing
PixelFormat compares and hashes by its underlying FourCharCode
rather than by enum variant. This means
PixelFormat::BGRA == PixelFormat::Unknown(FourCharCode::from_bytes(*b"BGRA"))
— both round-trip to the same wire-level format — and they hash the
same. Without this normalisation, the user-facing Unknown(known_code)
footgun (constructing the variant with a code that already maps to a
named variant) would silently produce two PixelFormat values that
represent the same underlying format but compared unequal and indexed
HashMaps twice.
§Examples
use screencapturekit::stream::configuration::PixelFormat;
use screencapturekit::FourCharCode;
let format = PixelFormat::BGRA;
println!("Format: {}", format); // Prints "BGRA"
// Equality normalises through FourCharCode:
let synonym = PixelFormat::Unknown(FourCharCode::from_bytes(*b"BGRA"));
assert_eq!(PixelFormat::BGRA, synonym);Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
BGRA
Packed little endian ARGB8888 (most common)
l10r
Packed little endian ARGB2101010 (10-bit color)
YCbCr_420v
Two-plane “video” range YCbCr 4:2:0
YCbCr_420f
Two-plane “full” range YCbCr 4:2:0
xf44
Two-plane “full” range YCbCr10 4:4:4 (10-bit)
RGhA
64-bit RGBA IEEE half-precision float, 16-bit little-endian (HDR)
Unknown(FourCharCode)
A pixel format reported by ScreenCaptureKit that this crate does not
model as a named variant. The wrapped FourCharCode preserves the
raw four-character code so callers can branch on it explicitly or
log it for diagnostics.
Trait Implementations§
Source§impl Clone for PixelFormat
impl Clone for PixelFormat
Source§fn clone(&self) -> PixelFormat
fn clone(&self) -> PixelFormat
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more