<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/vImage/PixelBuffer/withUnsafeVImageBuffers(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "s:10Accelerate6vImageO11PixelBufferVA2A013MultiplePlaneC6FormatRzrlE23withUnsafeVImageBuffersyqd__qd__SaySo01vb1_D0VGKXEKlF"
  },
  "title" : "withUnsafeVImageBuffers(_:)"
}
-->

# withUnsafeVImageBuffers(_:)

Calls the given closure with the underlying vImage buffers.

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

## Parameters

`body`

A closure with a [`vImage_Buffer`](/documentation/Accelerate/vImage_Buffer) parameter that points to the underlying vImage buffers of the pixel buffer.

## Return Value

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

## 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:

```swift
 let src = vImage.PixelBuffer<vImage.Planar8x4>(size: vImage.Size(width: 32,
                                                                 height: 64))

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

---

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)