【问题标题】:Scaling images and save them缩放图像并保存它们
【发布时间】:2011-09-03 14:11:35
【问题描述】:

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

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

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

【问题讨论】:

    标签: iphone uiimageview uiimagepickercontroller image-scaling image-resizing


    【解决方案1】:

    最简单的方法是使用NYXImagesUtilities

    这是github page

    使用它的基本示例。

    // #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];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-24
      • 1970-01-01
      • 2013-12-12
      • 1970-01-01
      • 1970-01-01
      • 2018-05-09
      • 2023-04-04
      • 1970-01-01
      相关资源
      最近更新 更多