-(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 pixelBuffer1 = [self createPixelBufferWithSize: CGSizeMake(540, 960)];
static CIContext *_ciContext;
CIImage *outputImage = [CIImage imageWithTexture:textureId size:CGSizeMake(540, 960) flipped:YES colorSpace:NULL];
if( outputImage != nil) {
if( _ciContext == nil) {
_ciContext = [CIContext contextWithEAGLContext: [EAGLContext currentContext] options:@{kCIContextWorkingColorSpace : [NSNull null]} ];
}
[_ciContext render: outputImage toCVPixelBuffer: pixelBuffer1 bounds:[outputImage extent] colorSpace:NULL];
}