<!--
{
  "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/withUnsafePixelBuffers(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "s:10Accelerate6vImageO11PixelBufferVA2A013MultiplePlaneC6FormatRzrlE010withUnsafeC7Buffersyqd__qd__SayAEy_06PlanarcG0QzGGKXEKlF"
  },
  "title" : "withUnsafePixelBuffers(_:)"
}
-->

# withUnsafePixelBuffers(_:)

Calls the given closure with the array of pixel buffers that reference the individual planes.

```
func withUnsafePixelBuffers<R>(_ body: ([vImage.PixelBuffer<Format.PlanarPixelFormat>]) throws -> R) rethrows -> R
```

## Parameters

`body`

A closure with an array [`vImage.PixelBuffer`](/documentation/Accelerate/vImage/PixelBuffer) parameter that points to the underlying pixel buffers.

## Return Value

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

## Discussion

Use this function to access each individual planar pixel buffer of a multiple-plane pixel buffer. For example, the following code initializes a 4-channel interleaved pixel buffer from the first three pixel buffers of a 4-channel multiple-plane pixel buffer:

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

 src.withUnsafePixelBuffers { overlaySource8x4PixelBuffers in

     let dest = vImage.PixelBuffer<vImage.Interleaved8x3>(planarBuffers: [
         overlaySource8x4PixelBuffers[0],
         overlaySource8x4PixelBuffers[1],
         overlaySource8x4PixelBuffers[2]
     ])
 }
```

---

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)