【发布时间】:2012-03-07 20:19:53
【问题描述】:
由于我正在保存具有透明部分的图像,但在将其保存在 Document 文件夹中时,透明部分变为白色。
下面是代码......
NSData *dataPhoto = UIImageJPEGRepresentation(imageBigPhoto, 1.0);
//NSData *dataPhoto = UIImagePNGRepresentation(imageBigPhoto);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *fullPathWithFoldername=[documentsDirectory stringByAppendingFormat:@"/%@",[[NSUserDefaults standardUserDefaults]valueForKey:@"PhotoFolderName"]];
//NSLog(@"%@",fullPathWithFoldername);
NSString *fullPath = [fullPathWithFoldername stringByAppendingPathComponent:name];
[dataPhoto writeToFile:fullPath atomically:YES];
【问题讨论】:
-
我看到您已从 PNG 格式切换到 JPEG 格式。 PNG也有同样的问题吗?
-
JPEG 不做透明度。
标签: iphone uiimage document transparent uiimagejpegrepresentation