文件Base64以后会翻倍的涨,例如一张52kb的图片 base64以后string文件大小为185kb,在通过string转回图片为135kb
 
图片转文字:
UIImage *_originImage = [UIImage imageNamed:@"0.jpg"];

NSData *_data = UIImageJPEGRepresentation(_originImage, 1.0f);

NSString *_encodedImageStr = [_data base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
[_encodedImageStr writeToFile:@"/Users/Singer/Documents/0.txt" atomically:YES encoding:NSUTF8StringEncoding error:nil]; NSLog(@"===Encoded image:\n%@", _encodedImageStr);
 
 
文字转图片:
NSString *imageStr = [NSString stringWithContentsOfFile:@"/Users/Singer/Documents/0.txt" encoding:NSUTF8StringEncoding error:nil];
NSData *d = [[NSData alloc]initWithBase64EncodedString:imageStr options:NSDataBase64DecodingIgnoreUnknownCharacters];
UIImage *image = [UIImage imageWithData:d]; UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(, , , )];
imageView.image = image;
[self.view addSubview:imageView];
[d writeToFile:@"/Users/Singer/Documents/1111.jpg" atomically:YES];
 

最新文章

  1. Breakpoint is not hit
  2. Websphere 系列的https证书的配置说明
  3. mysql cluster 名词概念解读
  4. JavaEE系列之(二)commons-fileupload实现文件上传、下载
  5. linux驱动系列之调试环境搭建一
  6. 转:三十三、Java图形化界面设计——布局管理器之null布局(空布局)——即SWT中的绝对布局
  7. 全国各城市Uber客服联系方式(电话、邮箱、微博)
  8. VBA -excel --遍历行
  9. 【LeetCode练习题】Evaluate Reverse Polish Notation
  10. 【BZOJ1084】最大子矩阵(动态规划)
  11. pandas常用函数之shift
  12. 使用VirtualBox把IMG文件转换为VDI文件
  13. 关于div容器在ie6下默认高度不为0(存在默认高度)
  14. HDFS客户端的权限错误:Permission denied
  15. 上一篇是copy了整理网上的内容,这篇是一个推荐
  16. VS2013编译Qt5.2.1 32位静态库debug-and-release版及结果分享
  17. python就业班-淘宝-目录.txt
  18. 【题解】Uoj79一般图最大匹配
  19. swift一次 Attempt to present on whose view is not in the window hierarchy的解决方法
  20. pandas DataFrame行或列的删除方法

热门文章

  1. BZOJ 1106 立方体大作战
  2. [反汇编练习] 160个CrackMe之027
  3. 【JavaScript学习笔记】if使用
  4. javascript对象定义和操作
  5. [转载] FFmpeg API 变更记录
  6. switchover步骤切换
  7. Python使用os.listdir()函数来得目录内容的介绍
  8. Shell教程2-变量
  9. 树莓派 Linux 剪贴板
  10. XSS 前端防火墙(2):可疑模块拦截