Saving a screen cap to a UIImage?

Discussion in 'iOS Programming' started by Jakintosh™, Nov 19, 2010.

  1. Jakintosh™, Nov 19, 2010
    Last edited: Nov 19, 2010

    Jakintosh™ macrumors member

    Joined:
    Jun 21, 2007
    #1
    I have an app that uses a live feed from the camera (via a UIImagePickerController) with a cameraOverlay on top of it. I now want to take a "screen shot" of the screen and save that to a UIImage and write that to a view over top the live feed so that it appears that the camera input has paused. I have everything in place to do this, but I can't figure out how to grab a screen shot.

    Also, I'm using AVFoundation in another class to turn the Flash Torch on and off. Unfortunately this freezes my camera input from the UIImagePickerController for the rest of the program until I kill it... does anyone know why this happens?

    EDIT: It seems I might have to migrate all my camera code to AVFoundation? Can I have a live video feed if I use AVFoundation instead of UIImagePickerController?
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    This is the way to do it. If you look back through my posts you'll even find helpful sample code showing how to get each and every frame...
     
  3. Jakintosh™ thread starter macrumors member

    Joined:
    Jun 21, 2007
    #3
    Awesome, thanks. Is there a way to make camera overlay equivalent when using AVFoundation?
     
  4. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    Render your overlay into a CALayer that you've added to the preview view.
     

Share This Page