0

在我正在开发的应用程序中,我有一个部分让用户使用 UIImagePicker 加载图像(从他们的照片库或拍摄新照片),这样做通常会提供大图像分辨率..2500x2000(或类似的东西)

现在我将该图像加载到 UIImageView 中(让我们说 400x320)。然后,我允许用户选择其他图像/对象以覆盖在原始图像之上并移动它们/调整它们的大小,然后他们才能将新图片保存到他们的照片库或通过电子邮件发送。

我只是想知道保存图像的最佳方法是什么,以使图像分辨率仍然与原始图像一样高....现在我只是截取屏幕截图,但这给我留下了一张 400x320 的小图像。

谢谢!


所以我得到了我想要的,不知道我是否以正确的方式做到了。

这基本上就是我所做的。

//NEWWIDTH and NEWHEIGHT are double the width and height of the UIImageView that i can edit the pictures in 
CGSize newSize = CGSizeMake(NEWWIDTH, NEWHEIGHT);

UIGraphicsBeginImageContext(newSize);

//i'm resizing myOriginalImage before to how i want
[myOriginalImage drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];

UIImage *image;

//Here i go through all the other pictures i added on top and go the same drawInRect method for each of them...multiplying each value x,y,height,width by 2

UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return newImage;
4

1 回答 1

0

目前尚不清楚您是如何处理图像的。在我的应用程序中,我在一个简单的 UIView 中使用 Core Graphics 执行此操作,并且通过使用不同的位图上下文获得了类似的效果。在我看来,我这样做:

- (void)drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
[_model render:rect context:context];
}

当我想渲染全尺寸位图以保存时,我使用 CGBitmapContext 运行相同的渲染代码。

这可能不是你的选择,但它对我有用。

祝你好运!

于 2011-12-10T14:18:12.100 回答