码迷,mamicode.com
首页 > 其他好文 > 详细

将图片缩放(质量和比例变化)

时间:2015-03-11 10:52:49      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:图片处理

- (UIImage *)resizeImage:(UIImage *)image

             withQuality:(CGInterpolationQuality)quality

                    rate:(CGFloat)rate

{

UIImage *resized = nil;

CGFloat width = image.size.width * rate;

CGFloat height = image.size.height * rate;

UIGraphicsBeginImageContext(CGSizeMake(width, height));

CGContextRef context = UIGraphicsGetCurrentContext();

CGContextSetInterpolationQuality(context, quality);

[image drawInRect:CGRectMake(0, 0, width, height)];

resized = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return resized;

}

将图片缩放(质量和比例变化)

标签:图片处理

原文地址:http://blog.csdn.net/zh_2608/article/details/44195015

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!