将图片保存成png 或者jpg格式
-(void)saveImage:(UIImage*)image{
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]);
}
最新文章
- mysql练习题-查询同时参加计算机和英语考试的学生的信息-遁地龙卷风
- EventBus--出现的问题
- 如何去掉Eclipse里面自动追加的一些注释!!!内详
- React和ES6(二)ES6的类和ES7的property initializer
- WebDriver兼容SeleniumRC(基于C#)
- swift学习笔记之-自动引用计数
- JAX-RS 2.0 REST客户端编程实例
- 分布式全局不重复ID生成算法
- linux里的bootproto的none,static,dhcp有什么区别
- git将本地项目添加到github远程仓库
- www.iis.net
- MAC平台下mysql7.5的安装
- MongoDB学习总结(四) —— 索引的基本用法
- 利用wget检测网页是否正常访问
- hdu5893 List wants to travel
- 使用python UIAutomation从QQ2017(v8.9)群界面获取所有群成员详细资料,
- Swift之GCD使用指南1
- windows10下Kafka环境搭建
- day26_python_1124
- Mysql性能优化二:索引优化
热门文章
- Linux磁盘配额实验
- LWIP_STM32_ENC28J60_NETCONN_TCP_CLIENT(4)
- 第三弹:ZFNet
- 你会做Web上的用户登录功能吗?
- Java使用POI实现数据导出excel报表
- Thinking in scala (7)---- f(n)=f(n-1)+2f(n-2)+3f(n-3)
- Eclipse上Spring-tool的安装
- 【ural1297】 Palindrome
- 【推荐】PHP中格式化时间函数date与gmdate的区别 | 修改PHP的默认时区
- PHP检测获取内存信息