设为首页 加入收藏

TOP

UIImage 压缩
2014-11-24 07:25:03 】 浏览:2735
Tags:UIImage 压缩
1.改变图片大小
[cpp]
-(UIImage*)imageWithImage:(UIImage*)image scaledToSize:(CGSize)newSize
{
// Create a graphics image context
UIGraphicsBeginImageContext(newSize);
// Tell the old image to draw in this new context, with the desired
// new size
[image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
// Get the new image from the context
UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
// End the context
UIGraphicsEndImageContext();
// Return the new image.
return newImage;
}
2.改变图片质量
NSData *imageData = UIImageJPEGRepresentation(imageNew, 0.0001);
code
UIImage *imageNew;
imageNew = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
imageNew = [self imageWithImage:imageNew scaledToSize:CGSizeMake(100, 100)];
NSData *imageData = UIImageJPEGRepresentation(imageNew, 0.0001);
m_selectImage = [UIImage imageWithData:imageData];
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇POCO C++库学习和分析 -- 通知和.. 下一篇在字符串中找出连续最长的数字串

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目