objective c - How to convert CVPixelBufferGetBaseAddress call to Swift? -
maybe i'm first person doing in swift there seems nothing on net using &/inout uint8_t in swift. translate please? relationship bitwise?
objective-c
uint8_t *buf=(uint8_t *) cvpixelbuffergetbaseaddress(cvimgref);
swift attempt
let inout buf:uint8_t = here cvpixelbuffergetbaseaddress(cvimgref)
cvpixelbuffergetbaseaddress()
returns unsafemutablepointer<void>
, can converted uint8
pointer via
let buf = unsafemutablepointer<uint8>(cvpixelbuffergetbaseaddress(pixelbuffer))
update swift 3 (xcode 8):
if let baseaddress = cvpixelbuffergetbaseaddress(pixelbuffer) { let buf = baseaddress.assumingmemorybound(to: uint8.self) // `buf` `unsafemutablepointer<uint8>` } else { // `baseaddress` `nil` }