在我的应用程序中,我正在使用相机功能,并且我正在为相机使用叠加视图,一切正常。
问题是在保存图像时我不想保存整个图像我只想保存我在叠加视图中显示的图片。
请参阅下面两个屏幕之间的区别。
1)这是我在叠加视图中显示的内容:
2)这就是我得到的:
谢谢!提前
CGRect rect = self.overlayimage.frame;
UIGraphicsBeginImageContext(CGSizeMake(self.overlayimage.frame.size.width, self.overlayimage.frame.size.height));
// This is where we resize captured image
[(UIImage *)[info objectForKey:UIImagePickerControllerOriginalImage] drawInRect:rect];
captureimage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
制作 UIImagePickerController 的对象
imagePickerController.allowsEditing = YES;
并在 UIImagePickerController 的委托方法中获取裁剪后的图像
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *croppedImg = [info objectForKey:@"UIImagePickerControllerEditedImage"]; }