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-23-2009, 05:24 AM   #1 (permalink)
Registered Member
 
vikysaran's Avatar
 
Join Date: Jul 2009
Location: New Delhi
Posts: 130
vikysaran is on a distinguished road
Unhappy Picture Capture/Merge issue

See this image



on Grab button it opens camera/gallery. User selects or shoots image and presses choose button then picture comes inside above frame and looks like bellow.



now i have to save the image showing now with frame.

Tell me what to do. Is there any way to Capture screen? or how i can merge these photos to generate a new photo with frame.

Thanx & Regards-
Vaibhav Saran | Software Engineer
Neo Sypher Systems Pvt. Ltd.
New Delhi | India
E-Mail: vaibhav@golsonline.com
Website: www.rStrings.com

Last edited by vikysaran; 09-23-2009 at 08:28 AM.
vikysaran is offline   Reply With Quote
Old 09-23-2009, 08:06 AM   #2 (permalink)
Registered Member
 
rwenderlich's Avatar
 
Join Date: Aug 2009
Posts: 162
rwenderlich is on a distinguished road
Default

You can draw the images to a "virtual" graphics context and then convert that graphics context into an image.

For example you can write code that looks something like this:

Code:
UIGraphicsBeginImageContext(contextRect);

[frame drawInRect:frameRect];
[image drawInRect:imageRect];

UIImage *finalImage = UIGraphicsGetImageFromCurrentImageContext();
__________________
Check out my iPhone development blog!

Motivate yourself to become an expert with LevelMeUp!

--Ray Wenderlich
rwenderlich is offline   Reply With Quote
Old 09-23-2009, 08:26 AM   #3 (permalink)
Registered Member
 
vikysaran's Avatar
 
Join Date: Jul 2009
Location: New Delhi
Posts: 130
vikysaran is on a distinguished road
Default

Here is some code-

Code:
	UIGraphicsBeginImageContext(imgSave.bounds.size);
	[imgSave.layer renderInContext:UIGraphicsGetCurrentContext()];
	
	UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
	UIGraphicsEndImageContext();
	UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);
	NSLog(@"Saving To Gallery");
'imgSave' is the image view that needs to be save.
Before compile import 'QuartzCore.Framework' to application

I'm still looking for exact solution
__________________
Thanx & Regards-
Vaibhav Saran | Software Engineer
Neo Sypher Systems Pvt. Ltd.
New Delhi | India
Websites:
http://www.iphonesaura.com/
http://www.apptango.com/


Last edited by vikysaran; 10-03-2009 at 03:17 AM.
vikysaran is offline   Reply With Quote
Old 10-03-2009, 05:16 AM   #4 (permalink)
Registered Member
 
vikysaran's Avatar
 
Join Date: Jul 2009
Location: New Delhi
Posts: 130
vikysaran is on a distinguished road
Default

Quote:
Originally Posted by rwenderlich View Post
You can draw the images to a "virtual" graphics context and then convert that graphics context into an image.

For example you can write code that looks something like this:

Code:
UIGraphicsBeginImageContext(contextRect);

[frame drawInRect:frameRect];
[image drawInRect:imageRect];

UIImage *finalImage = UIGraphicsGetImageFromCurrentImageContext();
I tried this-
Code:
	CGRect contextRect  = CGRectMake(-100, -100, 226, 155);
	UIGraphicsBeginImageContext(contextRect.size);	

	[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];

	UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
	UIGraphicsEndImageContext();
	UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);
But the resulting image is starting from origin (0,0) of screen whether I'm giving anything for x and y. But height and width are working as defined. Any solution for this?

thanx for you reply. It really worked for me
__________________
Thanx & Regards-
Vaibhav Saran | Software Engineer
Neo Sypher Systems Pvt. Ltd.
New Delhi | India
Websites:
http://www.iphonesaura.com/
http://www.apptango.com/

vikysaran is offline   Reply With Quote
Old 10-08-2009, 11:35 PM   #5 (permalink)
Registered Member
 
Join Date: Apr 2009
Posts: 2
Sana is on a distinguished road
Default

Quote:
Originally Posted by vikysaran View Post
I tried this-
Code:
	CGRect contextRect  = CGRectMake(-100, -100, 226, 155);
	UIGraphicsBeginImageContext(contextRect.size);	

	[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];

	UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
	UIGraphicsEndImageContext();
	UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);
But the resulting image is starting from origin (0,0) of screen whether I'm giving anything for x and y. But height and width are working as defined. Any solution for this?

thanx for you reply. It really worked for me
try using [self.yourView.layer renderInContext:UIGraphicsGetCurrentContext()];

instead of [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
where "yourView" you want to capture.

Hope it helps
Sana is offline   Reply With Quote
Old 10-09-2009, 12:08 AM   #6 (permalink)
Registered Member
 
vikysaran's Avatar
 
Join Date: Jul 2009
Location: New Delhi
Posts: 130
vikysaran is on a distinguished road
Default

Quote:
Originally Posted by Sana View Post
try using [self.yourView.layer renderInContext:UIGraphicsGetCurrentContext()];

instead of [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
where "yourView" you want to capture.

Hope it helps
if yourView -> UIImageView then it is not working. it shows error: request for member 'yourView' in something not a structure or union
Same error in case of UIImage also

somewhat i fullfilled my requirement. On Save click I'm displaying image on top and as saving finishes, it is back to previous view so the process is so quick that user cant not see the image on top.
__________________
Thanx & Regards-
Vaibhav Saran | Software Engineer
Neo Sypher Systems Pvt. Ltd.
New Delhi | India
Websites:
http://www.iphonesaura.com/
http://www.apptango.com/

vikysaran 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: 348
10 members and 338 guests
givensur, glenn_sayers, guusleijsten, ipodphone, jbro, mediaspree, mtl_tech_guy, Punkjumper, whitey99, yys
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,114
Posts: 402,883
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

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