gpt4 book ai didi

iphone - 在相机叠加层中创建我们自己的裁剪矩形

转载 作者:可可西里 更新时间:2023-11-01 05:42:18 25 4
gpt4 key购买 nike

我想说明我的基本要求,即在相机的 UIImagePickerController 中更改裁剪矩形的框架。

我刚刚意识到无法更改裁剪矩形的框架。这让我只有一个选择,即创建我自己的相机覆盖,我可以在其中设置裁剪矩形的框架。我搜索了很多但一无所获。我问了previously但没有得到任何东西。我什至不知道这是否可能,如果是,那么如何创建它并移动裁剪框,根据默认 UIImagePickerController 裁剪矩形缩放它。

最佳答案

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

[picker setAllowsEditing:NO];

然后在didFinishPickingMediaWithInfo delegate Push your own CropRect View

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

在推送 View 时像这样将图像传递给自定义 View

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

在该 customView 中裁剪图像。

要裁剪图像,请尝试这样......

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

关于iphone - 在相机叠加层中创建我们自己的裁剪矩形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10118955/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com