0

次のコードを使用して、uiimagePickerController からスクリーン ショットを取得しようとしています。

UIGraphicsBeginImageContext(imagePicker.view.bounds.size);
[self.imagePicker.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

カメラからキャプチャしているものを除くすべてが表示されます。キャンセルボタンが表示され、写真を撮るボタンが表示されます。カメラに表示されているものの代わりに、黒い画面をキャプチャしています。これを回避する方法はありますか? または、カメラから 1 秒ごとに画像を自動的にキャプチャするより良い方法はありますか?

- (void)captureOutput:(AVCaptureOutput *)captureOutput 
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer 
       fromConnection:(AVCaptureConnection *)connection
{ 
    UIImage *image = [self imageFromSampleBuffer:sampleBuffer];
    UIImageView *img = [[UIImageView alloc] initWithImage:image];
    [img setFrame:CGRectMake(0, 0, 320, 480)];
    [self.view addSubview:img];
    [img release];
}
4

1 に答える 1

1

新しい (OS 4 の) AVFoundation API を使用したい。

いくつかの情報については、このページを試してください:

http://developer.apple.com/iphone/library/qa/qa2010/qa1702.html

于 2010-08-21T22:30:16.133 に答える