3

I've been using UIGetScreenImage() to get a screenshot of a UIImagePickerController. Basically I use the camera overlay and then when I take the screenshot, I have the image that the camera preview had been showing and my overlay on there too, which is exactly what I need.

Now UIGetScreenImage() has been banned, I've not been able to find a way to do this. It just shows black for the camera.

Edit: all of my other views are showing absolutely fine, just not the actual camera preview. Any ideas??!?!?

Here's the code I am using at the moment.


UIGraphicsBeginImageContext(picker.view.bounds.size);
[picker.view.layer renderInContext:UIGraphicsGetCurrentContext()];
CGContextDrawImage(context, bounds, camView.CGImage);
UIImage* screenImage = UIGraphicsGetImageFromCurrentImageContext();
UIImageWriteToSavedPhotosAlbum(screenImage, nil, nil, nil); 
UIGraphicsEndImageContext();

Any ideas how I can get the overlay + the camera image?

Thanks!

fdf33
  • 73
  • 1
  • 9

2 Answers2

0

This is slightly different than yours.

CGRect screenRect = [[UIScreen mainScreen] bounds];
        UIGraphicsBeginImageContext(screenRect.size);
        [self.layer renderInContext:UIGraphicsGetCurrentContext()];
        UIImage *sShot = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
        UIImageWriteToSavedPhotosAlbum (sShot, nil, nil, nil);

Does that work?

If not, you might want to try asking over at iphonedevsdk.com since they specialize in all things iPhone.

Ryan
  • 3,127
  • 6
  • 32
  • 48
  • Thanks, I gave that a go and it gave the same results (the view underneath the UIImagePickerController. I'll post a question over there too and see if anyone has done this before. – fdf33 Jul 27 '10 at 18:03
0

Have them take a picture. Then overlay your image on top of it.

Create a UIImage from two other UIImages on the iPhone

Community
  • 1
  • 1
Lou Franco
  • 87,846
  • 14
  • 132
  • 192
  • Thanks, that's a little too much though. Only need the image to be taken from the view itself. I might have to go down that route though. – fdf33 Jul 27 '10 at 18:08
  • I think the reason that the API was removed is because its a security violation for you to get a screenshot without user intervention. There are ways to violate privacy that way, I think. Not sure if that's right, but otherwise, I don't have a good explanation of why it was removed with no alternative. – Lou Franco Jul 27 '10 at 19:53
  • Thanks for the explanation though! I'm sure there's a way to do it and stay within the guidelines, just annoying is all! – fdf33 Jul 27 '10 at 20:00