#CoreImage - Render a CIImage to an Intermediate CVPixelBuffer Backed Image
This is useful if you're previewing several core image effects on the same image.
@implementation CIContext (IntermediateImage) | |
- (CIImage *)rsq_renderToIntermediateImage:(CIImage *)image { | |
CIImage *intermediateImage = nil; | |
CGSize size = image.extent.size; | |
CVPixelBufferRef pixelBuffer = NULL; | |
CVReturn status = CVPixelBufferCreate(kCFAllocatorDefault, | |
size.width, | |
size.height, | |
kCVPixelFormatType_32ARGB, | |
(__bridge CFDictionaryRef) @{(__bridge NSString *) kCVPixelBufferIOSurfacePropertiesKey: @{}}, | |
&pixelBuffer); | |
if (status == kCVReturnSuccess) { | |
[self render:image toCVPixelBuffer:pixelBuffer]; | |
intermediateImage = [CIImage imageWithCVPixelBuffer:pixelBuffer]; | |
} | |
CVPixelBufferRelease(pixelBuffer); | |
return intermediateImage; | |
} | |
@end |
I get a slightly blinking result on replaykit SampleBuffer CallBack after applying the [render:image toCVPixelBuffer:pixelBuffer] function
Device: iphone 7 Plus ,IOS 12