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 06-10-2011, 07:20 PM   #1 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 17
joe_mac_112283 is on a distinguished road
Default Take custom screenshot

I am making an app where the user can stack text and images on top of an image view. I cannot figure out how to take a screenshot of only the image view capturing it and everything on top of it. The image view is usually about 250x320 but it can vary and be anywhere on the screen.

This is the code I'm working with:

UIGraphicsBeginImageContext(self.view.frame.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);

I've been messing with this code for a while and can't figure out how to get it to work right. I am getting all kinds of weird results, and I cannot find a method that will take a CGPoint. I think that is what I'm missing.

Thank you very much...
joe_mac_112283 is offline   Reply With Quote
Old 06-11-2011, 04:43 AM   #2 (permalink)
Registered Member
 
sacha1996's Avatar
 
Join Date: Mar 2011
Posts: 415
sacha1996 is on a distinguished road
Default

Quote:
Originally Posted by joe_mac_112283 View Post
I am making an app where the user can stack text and images on top of an image view. I cannot figure out how to take a screenshot of only the image view capturing it and everything on top of it. The image view is usually about 250x320 but it can vary and be anywhere on the screen.

This is the code I'm working with:

UIGraphicsBeginImageContext(self.view.frame.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);

I've been messing with this code for a while and can't figure out how to get it to work right. I am getting all kinds of weird results, and I cannot find a method that will take a CGPoint. I think that is what I'm missing.

Thank you very much...
http://www.iphonedevsdk.com/forum/ip...ne-images.html
sacha1996 is offline   Reply With Quote
Old 06-11-2011, 12:04 PM   #3 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 17
joe_mac_112283 is on a distinguished road
Default It's not working correctly.

Quote:
Originally Posted by sacha1996 View Post
This is what I am trying:

UIGraphicsBeginImageContext(self.view.frame.size);
CGContextRef theContext = UIGraphicsGetCurrentContext();
[self.view.layer renderInContext:theContext];

CGRect overDrawRects[] = {CGRectMake(10, 0, 1, Picture_ImageView.frame.size.height), CGRectMake(Picture_ImageView.frame.size.width - 11, 0, 1, Picture_ImageView.frame.size.height)};

[[UIColor clearColor] set];

for (int i = 0; i < 2; i++) {
UIRectFill(overDrawRects[i]);
CGContextSaveGState(theContext);
CGContextClipToRect(theContext, overDrawRects[i]);
CGContextTranslateCTM(theContext, -1, 0);
[Picture_ImageView.layer renderInContext:theContext];
CGContextRestoreGState(theContext);
}

UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(theImage, nil, nil, nil);

It saves the entire screen. It does save the layers on top of my image view but I only want to take a screenshot of the screen where my image view is located. I have tried switching out self.view for Picture_ImageView and all kinds of variations of that with no success.
joe_mac_112283 is offline   Reply With Quote
Old 06-12-2011, 02:26 AM   #4 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

here you should see a snippet to do what you want...
http://www.iphonedevsdk.com/forum/ip...ne-images.html
__________________
dany_dev is offline   Reply With Quote
Reply

Bookmarks

Tags
save, saving, screenshot

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: 318
7 members and 311 guests
chemistry, Dnnake, iOS.Lover, jenniead38, lendo, Leslie80, pbart
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,664
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Leslie80
Powered by vBadvanced CMPS v3.1.0

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