[objective-c]UIImageをpng形式ファイルで保存
カメラロールにpngで保存
-(void)savePhotoPng:(UIImage*)orizinalSizeImage{ NSData *imageData = UIImagePNGRepresentation(orizinalSizeImage); UIImage *pngimage = [UIImage imageWithData:imageData]; UIImageWriteToSavedPhotosAlbum(pngimage, self, @selector(image:didFinishSavingWithError:contextInfo:), nil); }
Documentsフォルダにファイルとして保存
-(NSString*)getPathByFileName:(NSString*)fileName{ NSString* path=[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]; return [path stringByAppendingPathComponent:fileName]; } NSString*path=[self getPathByFileName:@"test.png"]; NSData*d=UIImagePNGRepresentation(uiimg); if ([d writeToFile:path atomically:YES]) { NSLog(@"save OK - %@",path); }else{ NSLog(@"save NG - %@",path); }