Locks the base address of the pixel buffer.


func CVPixelBufferLockBaseAddress(_ pixelBuffer: CVPixelBuffer, _ lockFlags: CVPixelBufferLockFlags) -> CVReturn



The pixel buffer whose base address you want to lock.


Either readOnly or 0; see CVPixelBufferLockFlags for discussion.

Return Value

A Core Video result code. See Core Video Constants for possible values.


You must call the CVPixelBufferLockBaseAddress(_:_:) function before accessing pixel data with the CPU, and call the CVPixelBufferUnlockBaseAddress(_:_:) function afterward. If you include the readOnly value in the lockFlags parameter when locking the buffer, you must also include it when unlocking the buffer.

See Also

Modifying Pixel Buffers

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software