方法

//Resize image

- (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;
}

  

使用

UIImageView *theImageView = [[UIImageView alloc]init];

    theImageView.frame = CGRectMake(0, 64, 320, 400);

    UIImage *aImage = [UIImage imageNamed:@"shenlin.png"];

    UIImage *resizeImage = [self resizeImage:aImage withQuality:kCGInterpolationNone rate:0.2];
theImageView.image = resizeImage;
theImageView.frame = CGRectMake(0, 64, resizeImage.size.width, resizeImage.size.height);
NSLog(@"%@",NSStringFromCGSize(resizeImage.size)); [self.view addSubview:theImageView];

  

最新文章

  1. 线程Thread
  2. 【读书笔记】读《编写高质量代码—Web前端开发修炼之道》 - JavaScript原型继承与面向对象
  3. Unix环境编程之定时、信号与中断
  4. shutdown -s -t
  5. 利用Java API通过路径过滤上传多文件至HDFS
  6. Windows命令行(DOS命令)教程–2 (转载) http://arch.pconline.com.cn//pcedu/rookie/basic/10111/15325_1.html
  7. Palindrome Subarrays
  8. 【原】spring boot在整合项目依赖的问题
  9. Python 执行字符串表达式函数(eval exec execfile)
  10. java文件创建、删除、读取、写入操作大全
  11. UIApplicationsharedApplication的常用使用方法
  12. JQuery 阻止事件冒泡
  13. URLconnection
  14. gitbook 入门教程之环境要求
  15. Proxmox VE登陆的时候提示没有有效的订阅You do not have a valid subscription for this server. Please visit www.proxmox.com to get a list of available options.
  16. 第16月第8天 NSInvocation存储 函数指针 va_arg lldb
  17. DDD领域模型系统的工作流(十四)
  18. linux系统安装pycharm环境
  19. Thrift 入门之helloWorld
  20. sql: Oracle 11g create table, function,trigger, sequence

热门文章

  1. [webpack] devtool里的7种SourceMap[转]
  2. 【UOJ 34】 #34. 多项式乘法 (FFT)
  3. Android之Fragment优点
  4. lightoj 1306 - Solutions to an Equation 扩展的欧几里得
  5. Java并发(十一):Condition条件
  6. [bzoj1021][SHOI2008]Debt 循环的债务 (动态规划)
  7. Powerdesigner打开工程提示打印错误 解决方法
  8. Spring依赖检查
  9. 计蒜之道 初赛 第三场 题解 Manacher o(n)求最长公共回文串 线段树
  10. UIBezierPath的使用(持续更新)