---
title: "CVPixelBufferCreate(_:_:_:_:_:_:)"
framework: corevideo
role: symbol
role_heading: Function
path: "corevideo/cvpixelbuffercreate(_:_:_:_:_:_:)"
---

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

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

## Declaration

```swift
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 doc://com.apple.documentation/documentation/CoreFoundation/kCFAllocatorDefault for the allocator parameter to use the default allocator. See doc://com.apple.documentation/documentation/CoreFoundation/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 doc://com.apple.corevideo/documentation/CoreVideo/pixel-buffer-attribute-keys for possible values.
- `pixelBufferOut`: On output, the newly created pixel buffer.

## Return Value

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

## Discussion

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. tip: If you need to create and release multiple pixel buffers, use CVPixelBufferPool to create a pixel buffer pool that efficiently reuses pixel buffer memory.

## See Also

### Creating pixel buffers

- [CVPixelBufferCreateWithBytes(_:_:_:_:_:_:_:_:_:_:)](corevideo/cvpixelbuffercreatewithbytes(_:_:_:_:_:_:_:_:_:_:).md)
- [CVPixelBufferCreateWithPlanarBytes(_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:)](corevideo/cvpixelbuffercreatewithplanarbytes(_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:).md)
- [CVPixelBufferCreateWithIOSurface(_:_:_:_:)](corevideo/cvpixelbuffercreatewithiosurface(_:_:_:_:).md)
