iphone – 你如何使用AVCaptureStillImageOutput,captureStillImageAsynchronouslyFromConnection?

iphone – 你如何使用AVCaptureStillImageOutput,captureStillImageAsynchronouslyFromConnection?,第1张

概述如何设置完成处理程序: captureStillImageAsynchronouslyFromConnection:completionHandler: for AVCaptureStillImageOutput? >(void)captureDelegate:(CMSampleBufferRef)缓冲区错误:(NSError *)错误; ? 使用块. 像这样的东西: [[self stillIm 如何设置完成处理程序:

captureStillImageAsynchronouslyFromConnection:completionHandler:

for AVCaptureStillimageOutput?

>(voID)captureDelegate:(CMSampleBufferRef)缓冲区错误:(NSError *)错误;

解决方法 使用块.
像这样的东西:

[[self stillimageOutput] captureStillimageAsynchronouslyFromConnection:vIDeoConnection                                                     completionHandler:^(CMSampleBufferRef imageDataSampleBuffer,NSError *error) {                                                         if (imageDataSampleBuffer != NulL) {                                                             NSData *imageData = [AVCaptureStillimageOutput jpegStillimageNSDataRepresentation:imageDataSampleBuffer];                                                             UIImage *image = [[UIImage alloc] initWithData:imageData];                                                                                                                              ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];                                                             [library writeImagetoSavedPhotosAlbum:[image CGImage]                                                                                       orIEntation:(ALAssetorIEntation)[image imageOrIEntation]                                                                                   completionBlock:^(NSURL *assetURL,NSError *error){                                                                                       if (error) {                                                                                           ID delegate = [self delegate];                                                                                           if ([delegate respondsToSelector:@selector(captureStillimageFailedWithError:)]) {                                                                                               [delegate captureStillimageFailedWithError:error];                                                                                           }                                                                                                                                                                                      }                                                                                   }];                                                             [library release];                                                             [image release];                                                         } else if (error) {                                                             ID delegate = [self delegate];                                                             if ([delegate respondsToSelector:@selector(captureStillimageFailedWithError:)]) {                                                                 [delegate captureStillimageFailedWithError:error];                                                             }                                                         }                                                     }];
总结

以上是内存溢出为你收集整理的iphone – 你如何使用AVCaptureStillImageOutput,captureStillImageAsynchronouslyFromConnection?全部内容,希望文章能够帮你解决iphone – 你如何使用AVCaptureStillImageOutput,captureStillImageAsynchronouslyFromConnection?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1059686.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-25
下一篇2022-05-25

发表评论

登录后才能评论

评论列表(0条)

    保存