Contents

CVPixelBufferCreate(_:_:_:_:_:_:)

Creates a single pixel buffer for a given size and pixel format.

Declaration

func CVPixelBufferCreate(_ allocator: CFAllocator?, _ width: Int, _ height: Int, _ pixelFormatType: OSType, _ pixelBufferAttributes: CFDictionary?, _ pixelBufferOut: UnsafeMutablePointer<CVPixelBuffer?>) -> CVReturn

Parameters

  • allocator:

    The allocator to use for creating the buffer pool. Pass Kcfallocatordefault for the allocator parameter to use the default allocator. See Predefined Allocators for additional values you can use.

  • 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 four-character code.

  • pixelBufferAttributes:

    An optional dictionary that contains the attributes for the pixel buffer. See Pixel Buffer Attribute Keys for possible values.

  • pixelBufferOut:

    On output, the newly created pixel buffer.

Return Value

A Core Video result code. See Result Codes for possible values.

Discussion

Some of the parameters specified in this function override equivalent pixel buffer attributes. For example, if you set values for the kCVPixelBufferWidthKey and kCVPixelBufferHeightKey keys in the pixelBufferAttributes dictionary, the values for the width and height parameters override the values in the dictionary.

Use CVPixelBufferRelease to release ownership of the pixelBufferOut object when you’re done with it.

See Also

Creating pixel buffers