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

View Single Post
Old 10-03-2009, 04:23 AM   #39 (permalink)
vikysaran
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 fladnag View Post
I am all of a sudden getting the same problem as filharvey is. The code worked for a few days then suddenly stopped working.
I've tried two variations of the script as below and they both have the same results - "taking" a screen shot but adding only a white image to the photo library. Anyone have a guess as to what is going on?

Code:
//THIS WORKED THEN STOPPED WORKING
		UIGraphicsBeginImageContext(self.window.bounds.size);
		[self.window.layer renderInContext:UIGraphicsGetCurrentContext()];
		UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
		UIGraphicsEndImageContext();
		UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);

		//THIS IS NOT WORKING EITHER
		CGRect screenRect = [[UIScreen mainScreen] bounds];
		UIGraphicsBeginImageContext(screenRect.size);
		
		CGContextRef ctx = UIGraphicsGetCurrentContext();
		[[UIColor blackColor] set];
		CGContextFillRect(ctx, screenRect);
		
		[self.window.layer renderInContext:ctx];
		
		UIImage *screenImage = UIGraphicsGetImageFromCurrentImageContext();
		UIImageWriteToSavedPhotosAlbum(screenImage, nil, nil, nil);
		UIGraphicsEndImageContext();
i made a little modification and it is working here

Code:
	CGRect contextRect  = CGRectMake(50, 50, 200, 200);// whatever you need
	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.
thanx for the code anyway...
__________________
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 05:13 AM.
vikysaran is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 175,281
Threads: 93,958
Posts: 402,311
Top Poster: BrianSlick (7,971)
Welcome to our newest member, SDP
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:45 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.