美文网首页
手动生成 CVPixelBufferRef

手动生成 CVPixelBufferRef

作者: 童冀 | 来源:发表于2017-04-13 16:22 被阅读451次

    深入理解 CVPixelBufferRef
    通过这个可以看清楚CVPixelBufferRef的构成

    +(CVPixelBufferRef)createPixelBufferWithSize:(CGSize)size {
        const void *keys[] = {
            kCVPixelBufferOpenGLESCompatibilityKey,
            kCVPixelBufferIOSurfacePropertiesKey,
        };
        const void *values[] = {
            (__bridge const void *)([NSNumber numberWithBool:YES]),
            (__bridge const void *)([NSDictionary dictionary])
        };
        
        OSType bufferPixelFormat = kCVPixelFormatType_32BGRA;
        
        CFDictionaryRef optionsDictionary = CFDictionaryCreate(NULL, keys, values, 2, NULL, NULL);
        
        CVPixelBufferRef pixelBuffer = NULL;
        CVPixelBufferCreate(kCFAllocatorDefault,
                            size.width,
                            size.height,
                            bufferPixelFormat,
                            optionsDictionary,
                            &pixelBuffer);
        
        CFRelease(optionsDictionary);
        
        return pixelBuffer;
    }
    

    相关文章

      网友评论

          本文标题:手动生成 CVPixelBufferRef

          本文链接:https://www.haomeiwen.com/subject/lvwbattx.html