如何在Swift中初始化CVPixelBufferRef
发布时间:2020-12-14 02:26:18 所属栏目:百科 来源:网络整理
导读:我们曾经如下初始化CVPixelBufferRef. CVPixelBufferRef pxbuffer = NULL; 但是在Swift中我们不能使用NULL,所以我们尝试了以下但当然XCODE希望我们将它用于初始化以使用它 let pxbuffer: CVPixelBufferRef 但怎么样? 在Obj_C中,我们正在创建这样的缓冲区,但
我们曾经如下初始化CVPixelBufferRef.
CVPixelBufferRef pxbuffer = NULL; 但是在Swift中我们不能使用NULL,所以我们尝试了以下但当然XCODE希望我们将它用于初始化以使用它 let pxbuffer: CVPixelBufferRef 但怎么样? 在Obj_C中,我们正在创建这样的缓冲区,但正如我在转换为Swift时尝试解释的那样,我已经在第一行停止了. CVPixelBufferRef pxbuffer = NULL; CVPixelBufferCreate(kCFAllocatorDefault,picGenislik,frameHeight,kCVPixelFormatType_32ARGB,(__bridge CFDictionaryRef) options,&pxbuffer);
使用
CVPixelBufferCreate(_:_:_:_:_:_:) 创建对象
添加一些演示代码,希望这对您有所帮助.另请阅读Using Legacy C APIs with Swift var keyCallBack: CFDictionaryKeyCallBacks var valueCallBacks: CFDictionaryValueCallBacks var empty: CFDictionaryRef = CFDictionaryCreate(kCFAllocatorDefault,nil,&keyCallBack,&valueCallBacks) var attributes = CFDictionaryCreateMutable(kCFAllocatorDefault,1,&valueCallBacks); var iOSurfacePropertiesKey = kCVPixelBufferIOSurfacePropertiesKey withUnsafePointer(&iOSurfacePropertiesKey) { unsafePointer in CFDictionarySetValue(attributes,unsafePointer,empty) } var width = 10 var height = 12 var pixelBuffer: CVPixelBufferRef? = nil var status: CVReturn = CVPixelBufferCreate(kCFAllocatorDefault,width,height,kCVPixelFormatType_32BGRA,attributes,&pixelBuffer) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |