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

# withUnsafePointerToVImageBuffer(_:)

Calls the given closure with an unsafe pointer to the underlying vImage buffer.

## Declaration

```swift
func withUnsafePointerToVImageBuffer<R>(_ body: (UnsafePointer<vImage_Buffer>) throws -> R) rethrows -> R
```

## Parameters

- `body`: A closure with an unsafe pointer to a doc://com.apple.accelerate/documentation/Accelerate/vImage_Buffer parameter that points to the underlying vImage buffer 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 passes a pixel buffer to the C API vImageBufferFill_ARGB8888(_:_:_:) routine:  let src = vImage.PixelBuffer<vImage.Interleaved8x4>(size: vImage.Size(width: 128, height: 128))

src.withUnsafePointerToVImageBuffer { vImageBufferPtr in      _ = vImageBufferFill_ARGB8888(vImageBufferPtr,                                    [0, 0, 0, 0],                                    vImage_Flags(kvImageNoFlags))  }

## See Also

### Accessing underlying vImage buffers

- [withUnsafeVImageBuffer(_:)](accelerate/vimage/pixelbuffer/withunsafevimagebuffer(_:).md)
- [withUnsafeVImageBuffers(_:)](accelerate/vimage/pixelbuffer/withunsafevimagebuffers(_:).md)
