gpt4 book ai didi

iphone - UIImagePickerControllerEditedImage 问题

转载 作者:可可西里 更新时间:2023-11-01 04:40:22 26 4
gpt4 key购买 nike

我需要在将图像导入应用程序之前对其进行编辑,但在编辑图像后会降低一些质量如何避免这种情况?

- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

[self dismissModalViewControllerAnimated:YES];
imgEdited.image = [info objectForKey:UIImagePickerControllerEditedImage];


}

最佳答案

您可以使用通过 UIImagePickerControllerCropRect 提供的值手动裁剪 UIImagePickerControllerOriginalImage

未经测试的快速和肮脏的例子:

static UIImage *my_croppedImage(UIImage *image, CGRect cropRect)
{
UIGraphicsBeginImageContext(cropRect.size);
[image drawAtPoint:CGPointMake(-cropRect.origin.x, -cropRect.origin.y)];
UIImage *cropped = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return cropped;
}

- (void) imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
// …

UIImage *originalImage = info[UIImagePickerControllerOriginalImage];
CGRect cropRect = [info[UIImagePickerControllerCropRect] CGRectValue];
UIImage *croppedImage = my_croppedImage(originalImage, cropRect);

// …
}

关于iphone - UIImagePickerControllerEditedImage 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9904940/

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