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` } 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -