分享

ios 图片压缩

 ccccshq 2014-11-20
复制代码
 1 //对图片尺寸进行压缩--
 2 -(UIImage*)imageWithImage:(UIImage*)image scaledToSize:(CGSize)newSize
 3 {
 4     // Create a graphics image context
 5     UIGraphicsBeginImageContext(newSize);
 6     
 7     // Tell the old image to draw in this new context, with the desired
 8     // new size
 9     [image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
10     
11     // Get the new image from the context
12     UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
13     
14     // End the context
15     UIGraphicsEndImageContext();
16     
17     // Return the new image.
18    return newImage;
19 }
复制代码
//按比例压缩
NSData  *imageData = UIImageJPEGRepresentation(self.uploadImage , 0.75);

 

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多