Contents

vImageBuffer_CopyToCVPixelBuffer(_:_:_:_:_:_:)

Copies the contents of a vImage buffer to a Core Video pixel buffer.

Declaration

func vImageBuffer_CopyToCVPixelBuffer(_ buffer: UnsafePointer<vImage_Buffer>, _ bufferFormat: UnsafePointer<vImage_CGImageFormat>, _ cvPixelBuffer: CVPixelBuffer, _ cvImageFormat: vImageCVImageFormat!, _ backgroundColor: UnsafePointer<CGFloat>!, _ flags: vImage_Flags) -> vImage_Error

Parameters

  • buffer:

    The source vImage buffer.

  • bufferFormat:

    A Vimage_cgimageformat structure that specifies the image format of the Vimage_buffer structure. If Colorspace is nil, the function uses Srgb.

  • cvPixelBuffer:

    The destination Cvpixelbuffer instance. It’s not necessary to lock the pixel buffer before calling this function.

  • cvImageFormat:

    An optional Vimagecvimageformat instance that specifies the pixel format of the source pixel buffer. If this parameter is nil, the function attempts to derive this information from the Core Video pixel buffer.

  • backgroundColor:

    If the source image contains alpha information and the destination format doesn’t contain alpha information, this function flattens the source image against this parameter.

  • flags:

    The options to use when performing the operation. If your code implements its own tiling or its own multithreading, pass Kvimagedonottile; otherwise, pass Kvimagenoflags.

Return Value

kvImageNoError; otherwise, one of the error codes in Data Types and Constants.

Discussion

For compatibility with Core Video, vImage substitutes gamma 1/1.961 for kCVImageBufferTransferFunction_ITU_R_709_2 and substitutes the ITU-R BT.709-5 transfer function for kCVImageBufferTransferFunction_SMPTE_240M_1995. You can manually set the transfer function using vImageCreateRGBColorSpaceWithPrimariesAndTransferFunction(_:_:_:_:_:) and vImageCVImageFormat_SetColorSpace(_:_:) to avoid this substitution.