我正在编写一个将 AVFoundation 用于相机内容的 iPhone 应用程序,并且我正在尝试将 UIImage 从相机保存到相机胶卷中。
它目前是这样做的......
[imageCaptureOutput captureStillImageAsynchronouslyFromConnection:[imageCaptureOutput.connections objectAtIndex:0]
completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error)
{
if (imageDataSampleBuffer != NULL)
{
NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
UIImage *image = [[UIImage alloc] initWithData:imageData];
MyCameraAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[delegate processImage:image];
}
}];
我一直在观看 WWDC 教程视频,我认为从 imageDataSampleBuffer 到 UIImage 的 2 行(NSData... 和 UIImage...)是一个漫长的过程。
将图像保存到库似乎需要很长时间。
有谁知道是否有单行转换可以让 UIImage 脱离这个?
谢谢你的帮助!
奥利弗