日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

图片序列化和反序列化成图片文件(代码)

發(fā)布時間:2024/4/17 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 图片序列化和反序列化成图片文件(代码) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
// // ViewController.m // 圖片序列化和反序列化 // // Created by Qlinchao on 17/3/14. // Copyright ? 2017年 QLC. All rights reserved. // #import "ViewController.h"@interface ViewController () @property (weak, nonatomic) IBOutlet UIImageView *imageView;@end@implementation ViewController- (void)viewDidLoad {[super viewDidLoad];NSArray *dirArray = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);NSString *path = [dirArray firstObject];path = [path stringByAppendingPathComponent:@"imageTest.jpg"];UIImage *image = [UIImage imageNamed:@"login_register_background.png"];NSData *imageData = UIImageJPEGRepresentation(image, 1.0);BOOL isWrite = [imageData writeToFile:path atomically:YES];if (isWrite) {NSLog(@"寫入成功");} else {NSLog(@"寫入失敗");}}-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{[self readFile]; } -(void)readFile{NSArray *dirArray = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);NSString *path = [dirArray firstObject];path = [path stringByAppendingPathComponent:@"imageTest.jpg"];NSLog(@"%@",path);if([[NSFileManager defaultManager] fileExistsAtPath:path]){NSData *picData = [NSData dataWithContentsOfFile:path];self.imageView.image = [UIImage imageWithData:picData];} }@end

?

轉載于:https://www.cnblogs.com/sivek/p/6550579.html

總結

以上是生活随笔為你收集整理的图片序列化和反序列化成图片文件(代码)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。