PlatformImage
The Android form, wrapping a Bitmap.
The bitmap belongs to this object. Nothing else may hold it after close.
The Apple form, wrapping a CGImage.
Swift callers read pixels through toNSData and take a Core Image handle through toCIImage. The CGImage itself is not exposed.
A decoded frame, owned by the caller.
The pixels stay in whatever the platform decoded them into. Call close when you are done with the frame, from Kotlin or from Swift. Nothing else releases it for you.
Use toRgba8888 from Kotlin. Swift callers should use toNSData() on the Apple form of this class instead, which reads the same pixels without a per-byte bridged call.
The JVM form, wrapping a BufferedImage.
The image belongs to this object. Nothing else may hold it after close. There is no native buffer to free here, so close only drops the reference.
The browser form, holding an RGBA snapshot rather than a live frame.
This is the one place the browser cannot honour the common contract. VideoFrame.copyTo returns a Promise and there is no synchronous path to a frame's pixels, so the copy the common KDoc calls "always a copy" is paid before the image is constructed rather than inside toRgba8888. The signature holds. The sentence about pixels staying in whatever the platform decoded them into does not.
A PlatformImage costs widthPx * heightPx * 4 bytes of wasm heap for as long as it is open, so close it promptly and do not hold a strip of them.
Functions
The underlying image, still owned by this object.
Releases the underlying pixels. Idempotent, and using the image afterwards is a programming error.
Releases the underlying pixels. Idempotent, and using the image afterwards is a programming error.
Releases the underlying pixels. Idempotent, and using the image afterwards is a programming error.
Releases the underlying pixels. Idempotent, and using the image afterwards is a programming error.
Releases the underlying pixels. Idempotent, and using the image afterwards is a programming error.
Encodes this frame as a still image.
Copies the pixels out as tightly packed RGBA_8888, row-major, with no row padding.
The pixels are read in the frame's own color space wherever Core Graphics will take one. Naming a device space instead converts the frame on its way out, and a frame rendered for Rec.709 then stops matching the file the same pipeline encodes. A device space is the fallback for an image Core Graphics will not open a matching context for, such as a monochrome or CMYK one.
Copies the pixels out as tightly packed RGBA_8888, row-major, with no row padding.
Copies the pixels out as tightly packed RGBA_8888, row-major, with no row padding.
Copies the pixels out as tightly packed RGBA_8888, row-major, with no row padding.