如何在iphone的objective-c中以编程方式调整图像大小 [英] How to resize the image programmatically in objective-c in iphone

查看:81
本文介绍了如何在iphone的objective-c中以编程方式调整图像大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,我在一个小空间中显示大图像。
图像非常大,但我只在100x100像素的帧中显示它们。
由于我正在使用的图像大小,我的应用程序响应缓慢。

I have an application where I am displaying large images in a small space. The images are quite large, but I am only displaying them in 100x100 pixel frames. My app is responding slowly because of the size fo the images I am using.

为了提高性能,如何使用Objective-C以编程方式调整图像大小?

To improve performance, how can I resize the images programmatically using Objective-C?

推荐答案

请找到以下代码。

- (UIImage *)imageWithImage:(UIImage *)image convertToSize:(CGSize)size {
    UIGraphicsBeginImageContext(size);
    [image drawInRect:CGRectMake(0, 0, size.width, size.height)];
    UIImage *destImage = UIGraphicsGetImageFromCurrentImageContext();    
    UIGraphicsEndImageContext();
    return destImage;
}

这篇关于如何在iphone的objective-c中以编程方式调整图像大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆