在相机叠加中创建我们自己的裁剪矩形 [英] Creating our own crop rect in camera overlay

查看:133
本文介绍了在相机叠加中创建我们自己的裁剪矩形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在提出我的问题之前,我想说明我的基本要求,即在 UIImagePickerController 中为相机更改裁剪矩形框架。

我只是意识到,是不可能改变帧的crop rect。这让我只有一个选项,即创建自己的相机叠加,其中我可以设置帧的裁剪矩形。我搜索了很多,但什么也找不到。我问 之前 ,但没有得到任何结果。我甚至不知道是可能的,如果是,那么如何创建它,并移动裁剪框,缩放根据默认 UIImagePickerController 裁剪矩形。

有人可以帮我吗?

谢谢,

Nitish

Before placing my question, I want to state my basic requirement which is to change the frame for crop rect in UIImagePickerController for a camera.
I just realized that it is not possible to change frame for crop rect. That leaves me with only one option i.e to create my own camera overlay wherein I can set frame for crop rect. I searched a lot but found nothing. I asked previously but didn't get anything. I don't even know is it possible and if yes then how to create it and move the crop box, scale it in accordance to default UIImagePickerController crop rect.
Can someone help me here?
Thanks,
Nitish

推荐答案

你必须实现自己的CropRect。首先设置

You have to Implement your own CropRect. First set the

[picker setAllowsEditing:NO];

然后在 didFinishPickingMediaWithInfo 委托推送您自己的CropRect查看

Then in didFinishPickingMediaWithInfo delegate Push your own CropRect View

CustomImageEditor *custom = [[CustomImageEditor alloc] initWithNibName:@"CustomImageEditor" bundle:nil];
[picker pushViewController:custom animated:YES];
[custom release];

 UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
 custom.pickedImage = image;

在该自定义视图中裁剪图像。

In that customView you crop the image.

用于剪裁图像尝试这样..

For croping the image try like this..

CGImageRef imageRef = CGImageCreateWithImageInRect([image CGImage], cropRect);
UIImage *image = [UIImage imageWithCGImage:imageRef];

这篇关于在相机叠加中创建我们自己的裁剪矩形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆