UIImageã®ç»åãã¼ã¿ãPNGãã¡ã¤ã«ã«ä¿åããæ¹æ³
以ä¸ã®æ§ãªè¨è¿°ã§ ImageView ã«è¨å®ããã UIImage ã®ç»åãã¼ã¿ãã¢ããªã® Documents 以ä¸ã« test.png ã¨ããå称㧠ä¿åããã¾ãã
(ãµã³ãã«ã®å
¨ä½ã¯こちらããDLãã¦ä¸ãã)
- (IBAction)run:(id)sender { UIImage *image = ImageView.image; NSData *data = UIImagePNGRepresentation(image); NSString *filePath = [NSString stringWithFormat:@"%@/test.png" , [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]]; NSLog(@"%@", filePath); if ([data writeToFile:filePath atomically:YES]) { NSLog(@"OK"); } else { NSLog(@"Error"); } [data release]; }
JPEGãã¡ã¤ã«ã§åºåãããå ´åã¯ä»¥ä¸ã®æ§ã«è¨è¿°ãã¾ãã
NSData *data = UIImageJPEGRepresentation(image, 0.8f);