---
title: "CVMetalBufferCacheCreateBufferFromImage(_:_:_:_:)"
framework: corevideo
role: symbol
role_heading: Function
path: "corevideo/cvmetalbuffercachecreatebufferfromimage(_:_:_:_:)"
---

# CVMetalBufferCacheCreateBufferFromImage(_:_:_:_:)

## Declaration

```swift
func CVMetalBufferCacheCreateBufferFromImage(_ allocator: CFAllocator?, _ bufferCache: CVMetalBufferCache, _ imageBuffer: CVImageBuffer, _ bufferOut: UnsafeMutablePointer<CVMetalBuffer?>) -> CVReturn
```

## Parameters

- `allocator`: The CFAllocatorRef to use for allocating the CVMetalBuffer object. May be NULL.
- `bufferCache`: The buffer cache object that will manage the buffer.
- `bufferOut`: The newly created buffer object will be placed here.

## Return Value

Return Value Returns kCVReturnSuccess on success

## Discussion

Discussion Creates a CVMetalBuffer object from an existing CVImageBuffer Creates or returns a cached CVMetalBuffer object mapped to the CVImageBuffer. This creates a live binding between the CVImageBuffer and underlying CVMetalBuffer buffer object.         IMPORTANT NOTE: Clients should retain CVMetalBuffer objects until they are done using the images in them.         Retaining a CVMetalBuffer is your way to indicate that you're still using the image in the buffer, and that it should not be recycled yet.

## See Also

### Functions

- [CVMetalBufferCacheCreate(_:_:_:_:)](corevideo/cvmetalbuffercachecreate(_:_:_:_:).md)
- [CVMetalBufferCacheFlush(_:_:)](corevideo/cvmetalbuffercacheflush(_:_:).md)
- [CVMetalBufferCacheGetTypeID()](corevideo/cvmetalbuffercachegettypeid().md)
- [CVMetalBufferGetBuffer(_:)](corevideo/cvmetalbuffergetbuffer(_:).md)
- [CVMetalBufferGetTypeID()](corevideo/cvmetalbuffergettypeid().md)
