当用户使用相机时,我想获取 UIImagePickerController 上显示的图像。当我得到时,我想处理图像并显示而不是常规的相机视图。
但问题是当我想获得相机视图时,图像只是一个黑色矩形。
这是我的代码:
UIView *cameraView = [[[[[[imagePicker.view subviews] objectAtIndex:0]
subviews] objectAtIndex: 0]
subviews] objectAtIndex: 0];
UIGraphicsBeginImageContext( CGSizeMake(320, 427) );
[cameraView.layer renderInContext: UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
imageToDisplay.image = [PixelProcessing processImage: viewImage]; //In this case the image is black
//imageToDisplay.image = viewImage; //In this case the image is black too
//imageToDisplay.image = [UIImage imageNamed: @"icon.png"]; //In this case image is being displayed properly
我究竟做错了什么?
谢谢。