UIGraphicsBeginImageContextWithOptions使用及注意事项
来源:互联网 发布:线切割直线编程怎么编 编辑:程序博客网 时间:2024/05/01 04:58
/************************************************************************* *****************************绘图注意事项********************************** ************************************************************************* * UIGraphicsBeginImageContextWithOptions函数一定要有对应的 * UIGraphicsEndImageContext函数作为结尾,不然会有内存泄漏 * 这个结尾函数可以多层嵌套: * UIGraphicsBeginImageContextWithOptions(......); * UIGraphicsBeginImageContextWithOptions(......); * UIGraphicsEndImageContext(); * UIGraphicsEndImageContext(); */ UIGraphicsBeginImageContextWithOptions(vImg.frame.size, NO, 1.0); CGContextRef context = UIGraphicsGetCurrentContext(); // CGContextScaleCTM(context, -0.5, 1.0); // 缩放,为负时相当于翻转加缩放(不确定)// CGContextTranslateCTM(context, -300, 100); // 偏移 /************************************************************************ *******************************绘制图片*********************************** ************************************************************************* * 会等比例缩放到全图显示,而且会翻转(原因是坐标系不同) * 解决方法1:在绘制到context前通过矩阵垂直翻转坐标系 * CGContextTranslateCTM(context, 0, height); * CGContextScaleCTM(context, 1.0, -1.0); * 解决方法2:使用drawInRect方法(使用这个方法,绘制后和以前图片的宽高比例相同) * 解决方法3:颠倒画布 * glMatrixMode(GL_PROJECTION); * glLoadIdentity(); * glOrthof( 0, framebufferWidth, framebufferHeight, 0, -1, 1 ); *************************************************************************/ CGContextTranslateCTM(context, 0, vImg.frame.size.height); CGContextScaleCTM(context, 1.0, -1.0); CGContextDrawImage(context, vImg.bounds, img.CGImage); // 绘制图片,也可通过drawInRect方法 UIImage *uiImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();
0 0
- UIGraphicsBeginImageContextWithOptions使用及注意事项
- MagicAjax使用及注意事项
- MagicAjax使用及注意事项
- MagicAjax使用及注意事项
- SWFUpload 使用及注意事项
- wllvm使用及注意事项
- Service使用及注意事项
- HttpClient使用及注意事项
- UIView转UIImage(截屏,UIGraphicsBeginImageContextWithOptions函数的使用)
- 锂电池的使用及注意事项
- TreeMap的使用及注意事项
- openSessionInView的使用及注意事项
- 笔记本电及使用注意事项
- shared_ptr 的使用及注意事项
- IndexWriter基础使用及注意事项
- crontab 的使用及注意事项
- winpcap使用注意事项及常见问题
- Flashcache基本使用及注意事项
- SpringMVC源码分析--容器初始化(三)HttpServletBean
- HDU - 5505 GT and numbers 【GCD】
- linux菜鸟入门之文本处理小工具sed
- uva 11040 规律递推(水)
- 通过jdk自带xjc将xsd 快速生成java类
- UIGraphicsBeginImageContextWithOptions使用及注意事项
- 一个台阶总共有n级,如果一次可以跳1级,也可以跳2级。 求总共有多少总跳法,并分析算法的时间复杂度。
- 汉诺塔
- Linux 上git远程版本库的搭建
- leetcode合并两个已经排序的链表
- Android app中添加facebook原生广告,应该注意的坑
- 数组和结构的分辨
- linux下Java生成图片字体中文乱码问题
- DataGridView 设置某列值的对齐方式