1

由于我保存的图像具有透明部分,但将其保存在Document文件夹中时,透明部分变为白色。iPhone应用程序的文档文件夹中的透明UIImage

下面是代码....

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]; 
+0

我看到你已经从PNG切换到JPEG格式。 PNG是否有同样的问题? – Ariel 2012-03-07 11:29:41

+0

JPEG不会透明。 – ssteinberg 2012-03-07 11:30:25

回答

2

JPEG图像不支持透明度。 PNG图像。

1

我想你已经评论过你的PNG图像表示,JPEG表示不会保存透明度。只需启用您评论的代码并尝试。

相关问题