压缩UIImage但保持大小 [英] compress UIImage but keep size

查看:131
本文介绍了压缩UIImage但保持大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用 UIImageView 来显示照片。但照片有时候有点大,我想压缩它。但我想保持它的大小。
例如,一张照片是4M,尺寸为320X480。我想压缩它,它可能有1M但仍然有320X480的大小。

I try to use UIImageView to show the photo. But the Photo sometimes is a little large, and I want to compress it.But I'd like to keep its size. For example,a photo is 4M and has a size of 320X480. And I want to compress it and it may have 1M but still has a size of 320X480.

谢谢!

推荐答案

使用JPEG压缩对其进行压缩。

Compress it using the JPEG compression.

lowResImage = [UIImage imageWithData:UIImageJPEGRepresentation(highResImage, quality)];

质量介于0.0和1.0之间

Where quality is between 0.0 and 1.0

您应该阅读 UIImage文档,一切都在那里解释......

You should read the UIImage documentation, everything is explained in there…

这篇关于压缩UIImage但保持大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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