Contents

withUnsafeVImageBuffer(_:)

Calls the given closure with the underlying vImage buffer.

Declaration

func withUnsafeVImageBuffer<R>(_ body: (vImage_Buffer) throws -> R) rethrows -> R

Parameters

  • body:

    A closure with a Vimage_buffer parameter that points to the underlying vImage buffer 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 a pixel buffer’s underlying vImage buffer’s rowBytes property:

 let src = try vImage.PixelBuffer<vImage.Interleaved8x4>(cgImage: cgImage,
                                                         cgImageFormat: &cgImageFormat)

 src.withUnsafeVImageBuffer { vImageBuffer in
     print(vImageBuffer.rowBytes)
 }

See Also

Accessing underlying vImage buffers