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 originally had posted how to do a screen shot here, but then I saw that the poster knows how it's done - but wants to do it through code.
For some reason, it wont let me delete this post - so instead you're stuck reading garbage... sorry
__________________ www.sdkcoder.com
Are my posts helping you? Please help support my forum! Aiming to be one of the most comprehensive iPhone resources on the net.
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();
warning: no '-renderInContext:' method found
warning: (Messages without a matching method signature
warning: incomplete implementation of class 'VCMenu'
warning: method definition for '-renderInContext' not found
There are three applications that can be directly invoked (by just executing the program to take a screenshot, which can also be easily checked if you configure your Pocket PC to invoke the application straight from the Settings/Button applet or just click its icon in Start/Programs) and, therefore, be periodically run: PQV (for Portrait-only or game screenshot taking, strictly on QVGA devices), WebIS Inc.
warning: no '-renderInContext:' method found
warning: (Messages without a matching method signature
warning: incomplete implementation of class 'VCMenu'
warning: method definition for '-renderInContext' not found
you need to import the Quartz framework into your app, then include the header:
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
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...
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...
Did you find a solution about the problem it was starting at 0,0 ? I am looking for the same...