Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-11-2011, 08:35 PM   #1 (permalink)
Registered Member
 
Join Date: May 2011
Posts: 173
mistergreen2011 is on a distinguished road
Default How to save camera photo to your app directory instead of the photo album?

I'm reading up on the UIImagePickerController and its delegate. It seems like the photo you take goes into the device's photo album.
I need to access the photo I take in my app so I need in with the app. How do I do this? Override some method?

Thanks.
mistergreen2011 is offline   Reply With Quote
Old 09-11-2011, 10:02 PM   #2 (permalink)
Registered Member
 
Join Date: Oct 2008
Posts: 96
shan is on a distinguished road
Default

Here is a function to save an image to the Documents folder. Just pull the image in the delegate


Code:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
	UIImage *image = (UIImage *)[info objectForKey:UIImagePickerControllerOriginalImage];	 

	[self saveImagePNG:image withName:@"someimagename.png"];
}
Here is the method to save the image:

Code:
#define DOCSFOLDER [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]

- (void) saveImagePNG:(UIImage *)image withName:(NSString *)imageName{
	
	//get the image data
	NSData *tempData = UIImagePNGRepresentation(image);
	
	//save it to the documents folder
	NSString *filePath = [DOCSFOLDER stringByAppendingPathComponent:imageName];
	[[NSFileManager defaultManager] createFileAtPath:filePath contents:tempData attributes:nil];
	
}

Last edited by shan; 09-11-2011 at 10:05 PM.
shan is offline   Reply With Quote
Old 09-12-2011, 11:46 AM   #3 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 178
dustbyter is on a distinguished road
Default

Thanks for the example.

Handy code sample to have in the toolkit.
dustbyter is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 403
10 members and 393 guests
7twenty7, apatsufas, Eclectic, eski, fiftysixty, JackReidy, teebee74, tim0504, UMAD, yuncarl28
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,672
Threads: 94,121
Posts: 402,904
Top Poster: BrianSlick (7,990)
Welcome to our newest member, yuncarl28
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:04 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0