1.
- (void)displayLinkCallback:(CADisplayLink *) sender{ CMTime time = [snapshotOutput itemTimeForHostTime:CACurrentMediaTime()]; if ([snapshotOutput hasNewPixelBufferForItemTime:time]) { lastSnapshotPixelBuffer = [snapshotOutput copyPixelBufferForItemTime:time itemTimeForDisplay:NULL]; } } - (UIImage *)snapshotImage { if (lastSnapshotPixelBuffer) { CIImage *ciImage = [CIImage imageWithCVPixelBuffer:lastSnapshotPixelBuffer]; CIContext *context = [CIContext contextWithOptions:NULL]; CGRect rect = CGRectMake(0, 0, CVPixelBufferGetWidth(lastSnapshotPixelBuffer), CVPixelBufferGetHeight(lastSnapshotPixelBuffer)); CGImageRef cgImage = [context createCGImage:ciImage fromRect:rect]; return [UIImage imageWithCGImage:cgImage]; } return NULL; }