1

在我的应用程序中,用户可以通过相机拍摄图像或从相册中选择一张。(我将用相机拍摄的照片保存在相册中)。

在这两种情况下,我都想在文档目录中保存图像的缩放副本(640x920)。

如何进行缩放然后保存生成的图像?

4

1 回答 1

1

最简单的方法是使用NYXImagesUtilities

这是github页面

使用它的基本示例。

// #import <QuartzCore/QuartzCore.h> 
// #import "NYXImagesUtilities.h"
//.. path is an NSString of the documents directory + file name you want to save it to.
//.. myImage is the UIImage that you got from the user.

UIImage *scaledImage = [myImage scaleToFitSize:(CGSize){640, 920}];
[scaledImage saveToPath:path type:NYXImageTypePNG];
于 2011-05-27T18:23:36.053 回答