withUnsafePixelBuffers(_:)
Calls the given closure with the array of pixel buffers that reference the individual planes.
Declaration
func withUnsafePixelBuffers<R>(_ body: ([vImage.PixelBuffer<Format.PlanarPixelFormat>]) throws -> R) rethrows -> RParameters
- body:
A closure with an array 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:
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]
])
}