---
title: "withUnsafeVImageBuffers(_:)"
framework: accelerate
role: symbol
role_heading: Instance Method
path: "accelerate/vimage/pixelbuffer/withunsafevimagebuffers(_:)"
---

# withUnsafeVImageBuffers(_:)

Calls the given closure with the underlying vImage buffers.

## Declaration

```swift
func withUnsafeVImageBuffers<R>(_ body: ([vImage_Buffer]) throws -> R) rethrows -> R
```

## Parameters

- `body`: A closure with a doc://com.apple.accelerate/documentation/Accelerate/vImage_Buffer parameter that points to the underlying vImage buffers of the pixel buffer.

## Return Value

Return Value The return value, if any, of the body closure parameter.

## Discussion

Discussion Use this function to incorporate pixel buffer based image processing code with existing vImage code. For example, the following code accesses each multiple-plane pixel buffer’s underlying vImage buffers’ rowBytes property:  let src = vImage.PixelBuffer<vImage.Planar8x4>(size: vImage.Size(width: 32,                                                                  height: 64))

src.withUnsafeVImageBuffers { vImageBuffers in     for buffer in vImageBuffers {         print(buffer.rowBytes)      }  }

## See Also

### Accessing underlying vImage buffers

- [withUnsafePointerToVImageBuffer(_:)](accelerate/vimage/pixelbuffer/withunsafepointertovimagebuffer(_:).md)
- [withUnsafeVImageBuffer(_:)](accelerate/vimage/pixelbuffer/withunsafevimagebuffer(_:).md)
