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表示不會保存透明度。只需啓用您評論的代碼並嘗試。

相關問題