码迷,mamicode.com
首页 > 移动开发 > 详细

iOS 图片大小压缩 图片尺寸处理

时间:2015-06-17 14:50:57      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:

#pragma mark- 缩放图片 对大小压缩
+(UIImage *)scaleImage:(UIImage *)image toScale:(float)scaleSize
{
    //设置图片尺寸
    UIGraphicsBeginImageContext(CGSizeMake(image.size.width*scaleSize,image.size.height*scaleSize));
    [image drawInRect:CGRectMake(0, 0, image.size.width * scaleSize, image.size.height *scaleSize)];
    UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    //对图片包得大小进行压缩
    NSData *imageData = UIImageJPEGRepresentation(scaledImage,0.0001);
    UIImage *m_selectImage = [UIImage imageWithData:imageData];
    return m_selectImage;
}

 

//这样调用即可

        UIImage* original = [info objectForKey:UIImagePickerControllerOriginalImage];
        original = [HZSInstances scaleImage:original toScale:0.4];

 

iOS 图片大小压缩 图片尺寸处理

标签:

原文地址:http://www.cnblogs.com/huangzs/p/4582939.html

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