我在文件夹中有视网膜图像,需要重新绘制并再次保存。我做过类似的事情。
NSLog(@"%f",[UIScreen mainScreen].scale); // Scale Factor : 2.000000
NSLog(@"%@",NSStringFromCGSize(imgView.image.size)); // {4288, 2848} size : 2.6 MB
UIGraphicsBeginImageContextWithOptions(CGSizeMake(imgView.image.size.width, imgView.image.size.height), NO, [UIScreen mainScreen].scale);
[imgView drawViewHierarchyInRect:CGRectMake(0, 0, imgView.image.size.width, imgView.image.size.height) afterScreenUpdates:YES];
UIImage * image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSLog(@"%@",NSStringFromCGSize(image.size)); // {4288, 2848} size : 2.6 MB
NSString *path = [DOCUMENTPATH stringByAppendingPathComponent:@"image@2x.jpg"];
[UIImageJPEGRepresentation(image, 1.0) writeToFile:path atomically:true]; // {8576, 5696} size : 21.2 MB
问题:当我将图像保存在文档文件夹中时保存双倍分辨率和更大尺寸的实际图像
保存图片的最佳方法是什么?