<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.4.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreVideo",
  "identifier" : "/documentation/CoreVideo/CVPixelBufferCreate(_:_:_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Video"
    ],
    "preciseIdentifier" : "c:@F@CVPixelBufferCreate"
  },
  "title" : "CVPixelBufferCreate(_:_:_:_:_:_:)"
}
-->

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

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

```
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 [Pixel Buffer Attribute Keys](/documentation/CoreVideo/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](/documentation/CoreVideo/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`](/documentation/CoreVideo/kCVPixelBufferWidthKey) and [`kCVPixelBufferHeightKey`](/documentation/CoreVideo/kCVPixelBufferHeightKey) keys in the `pixelBufferAttributes` dictionary, the values for the `width` and `height` parameters override the values in the dictionary.

Use [`CVPixelBufferRelease`](/documentation/CoreVideo/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.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)