将UIView转成UIImage,将UIImage转成PNG/JPG
来源:互联网 发布:二次元扩列软件 编辑:程序博客网 时间:2024/06/02 14:58
- //UIView -> UIImage
- #import “QuartzCore/QuartzCore.h”
- //把UIView 转换成图片
- -(UIImage *)getImageFromView:(UIView *)view{
- UIGraphicsBeginImageContext(view.bounds.size);
- [view.layer renderInContext:UIGraphicsGetCurrentContext()];
- UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
- return image;
- }
- //UIImage -> PNG / JPG
- // Create paths to output images
- NSString*pngPath=[NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Test.png"];
- NSString*jpgPath=[NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Test.jpg"];
- // Write a UIImage to JPEG with minimum compression (best quality)
- // The value 'image' must be a UIImage object
- // The value '1.0' represents image compression quality as value from 0.0 to 1.0
- [UIImageJPEGRepresentation(image,1.0) writeToFile:jpgPath atomically:YES];
- // Write image to PNG
- [UIImagePNGRepresentation(image) writeToFile:pngPath atomically:YES];
- // Let's check to see if files were successfully written...
- // Create file manager
- NSError*error;
- NSFileManager*fileMgr=[NSFileManager defaultManager];
- // Point to Document directory
- NSString*documentsDirectory=[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
- // Write out the contents of home directory to console
- NSLog(@"Documents directory: %@", [fileMgr contentsOfDirectoryAtPath:documentsDirectory error:&error]);
http://blog.163.com/lzb4319@126/blog/static/7255470020125693048341/
- 将UIView转成UIImage,将UIImage转成PNG/JPG
- 将UIView转成UIImage,将UIImage转成PNG/JPG
- IOS 将UIView转成UIImage
- UIView转成UIImage
- 将UIImage对象保存到JPG或者PNG文件中
- 如何将.jpg 转成.eps
- 将yuv转成png图
- 如何把UIView转成UIImage,解决模糊失真问题
- 把UIView转成UIImage,解决模糊失真问题
- 如何把UIView转成UIImage,解决模糊失真问题
- 如何把UIView转成UIImage,解决模糊失真问题
- UIView 转化为 UIImage,将UIImage 保存到沙盒中
- 怎样将UIImage对象保存到JPG或者PNG文件中?
- iphone 怎样将UIImage对象保存到JPG或者PNG文件中?
- 怎样将UIImage对象保存到JPG或者PNG文件中?
- IOS将UIView转化为UIImage
- UIImage图片转成Base64字符串
- 怎样将jpg转成pdf格式
- Android 软件开发之如何使用Eclipse Debug调试程序详解
- POJ 1188 Gleaming the Cubes
- androidpn之xmpp分析
- 关于<AppName>-Prefix.pch文件的科幻用法
- XMLHTTPREQUEST IE下存在跨域问题
- 将UIView转成UIImage,将UIImage转成PNG/JPG
- KMP算法
- 外地回汉工作者公积金贷款门槛降低 出具外地6个月缴存证明即可贷款
- using git and repo
- 河北软件职业技术学院换届选举圆满成功
- 开发功能时的一般步骤 ------- 要严记
- top命令查看内存和多核CPU的使用
- 管理经验总结
- 河软CSDN高校俱乐部举办“我的程序员之路”讲座