次のコードを使用して、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];
}