Creates a single pixel buffer in planar format for a given size and pixel format containing data specified by a memory location.
SDKs
- iOS 4.0+
- macOS 10.4+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
Framework
- Core Video
Declaration
func CVPixelBufferCreateWithPlanarBytes(_ allocator: CFAllocator?, _ width: Int, _ height: Int, _ pixelFormatType: OSType, _ dataPtr: Unsafe Mutable Raw Pointer?, _ dataSize: Int, _ numberOfPlanes: Int, _ planeBaseAddress: Unsafe Mutable Pointer<Unsafe Mutable Raw Pointer?>, _ planeWidth: Unsafe Mutable Pointer<Int>, _ planeHeight: Unsafe Mutable Pointer<Int>, _ planeBytesPerRow: Unsafe Mutable Pointer<Int>, _ releaseCallback: CVPixel Buffer Release Planar Bytes Callback?, _ releaseRefCon: Unsafe Mutable Raw Pointer?, _ pixelBufferAttributes: CFDictionary?, _ pixelBufferOut: Unsafe Mutable Pointer<CVPixel Buffer?>) -> CVReturn
Parameters
allocator
The allocator to use to create this buffer. Pass
NULL
to specify the default allocator.width
The width of the pixel buffer, in pixels.
height
The height of the pixel buffer, in pixels.
pixelFormatType
The pixel format identified by its respective four-character code (type
OSType
).dataPtr
A pointer to a plane descriptor block if applicable, or
NULL
if it is not.dataSize
The size of the memory if the planes are contiguous, or
NULL
if it is not.numberOfPlanes
The number of planes.
planeBaseAddress
The array of base addresses for the planes.
planeWidth
The array of plane widths.
planeHeight
The array of plane heights.
planeBytesPerRow
The array of plane bytes-per-row values.
releaseCallback
The callback function that gets called when the pixel buffer is destroyed. This callback allows the owner of the pixels to free the memory. See
CVPixel
for more information.Buffer Release Bytes Callback releaseRefCon
A pointer to user data identifying the pixel buffer. This value is passed to your pixel buffer release callback.
pixelBufferAttributes
A dictionary with additional attributes for a a pixel buffer. This parameter is optional. See Pixel Buffer Attribute Keys for more details.
pixelBufferOut
On output, the newly created pixel buffer. Ownership follows the The Create Rule.
Return Value
A Core Video result code. See Core Video Constants for possible values.
Discussion
Some of the parameters specified in this call override equivalent pixel buffer attributes. For example, if you define the k
and k
keys in the pixel buffer attributes parameter (pixel
), these values are overridden by the width
and height
parameters.