Contents

withUnsafePointerToVImageBuffer(_:)

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

Declaration

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

Parameters

  • body:

    A closure with an unsafe pointer to 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 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