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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.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 03-22-2009, 03:55 PM   #1 (permalink)
Registered Member
 
DenVog's Avatar
 
Join Date: Jan 2009
Location: Silicon Valley, USA
Posts: 622
Question Combine Photo + Graphic and Save

I am trying to take a photo, overlay a graphic, then save it to the camera roll. I thought I had it figured out, but am running into two weird issues:
  1. If I press the Home button immediately after the "Saving photo" dialog completes, the photo does not save. If I count to ten before pushing the Home button it saves.
  2. When it does save, the overlay image is there but not the photo from the camera. In the Photo Albums Camera Roll row the preview image is black. If I open the photo it is all white, with my overlay image displayed on top.
Below is the code I am using, with comments for what I thought each line was doing.
Code:
#pragma mark -
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {
	// create a new bitmap image context with width of 1200 x 1600 to match camera output size
	UIGraphicsBeginImageContext(CGSizeMake(1200, 1600));		
	// get context
	CGContextRef context = UIGraphicsGetCurrentContext();		
	// push context to make it current (need to do this manually because we are not drawing in a UIView)
	UIGraphicsPushContext(context);								
	// drawing code comes here- look at CGContext reference for available operations
	// this example draws the overlayImage into the context
	UIImage *overlayImage = [UIImage imageNamed:@"overlay-image.png"];
	// x position, y position, height, width
	[overlayImage drawInRect:CGRectMake(160, 250, 160, 240)];
	// pop context Removes the current graphics context from the top of the stack, restoring the previous context, balance calls to the UIGraphicsPushContext function
	UIGraphicsPopContext();								
	// get a UIImage from the image context
	UIImage *outputImage = UIGraphicsGetImageFromCurrentImageContext();
	// clean up drawing environment
	UIGraphicsEndImageContext();
	// write the combined image to the photo album
	UIImageWriteToSavedPhotosAlbum(outputImage, nil, nil, nil);
	[self dismissModalViewControllerAnimated:YES];
}
Any help would be greatly appreciated. I've searched, checked out sample code, tried several different ways to implement, but am really hung up on this. Thanks.
DenVog is offline   Reply With Quote
Old 05-17-2009, 07:10 PM   #2 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 101
Default

hey denvog

any luck with figuring this out?

i'm trying to overlay an image while the camera is in viewfinder mode and then save that camera image along with the overlay image.

is that possible?
MikeBlah is offline   Reply With Quote
Old 05-18-2009, 12:30 PM   #3 (permalink)
Registered Member
 
DenVog's Avatar
 
Join Date: Jan 2009
Location: Silicon Valley, USA
Posts: 622
Default

Quote:
Originally Posted by MikeBlah View Post
hey denvog

any luck with figuring this out?

i'm trying to overlay an image while the camera is in viewfinder mode and then save that camera image along with the overlay image.

is that possible?
It is possible. There are several apps that do this today. Nice Photo for example.

I've gotten something very rough to work, but still run into a few issues that keep it being production ready. I've had to sit it aside for a while, but will eventually come back to it.
DenVog is offline   Reply With Quote
Reply

Bookmarks

Tags
camera, camera roll, photo

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: 254
15 members and 239 guests
@sandris, ADY, Alsahir, dacapo, Dani77, Desert Diva, djohnson, HemiMG, jansan, M@realobjects, MarkC, prchn4christ, smethorst, tomtom100
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,882
Threads: 89,228
Posts: 380,762
Top Poster: BrianSlick (7,129)
Welcome to our newest member, jansan
Powered by vBadvanced CMPS v3.1.0

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