0

How can i merge the captured photo from UIImagePickerController and cameraoverlay view? Then i want to save it to the photos album.

Need help on this.

vinay
  • 1,276
  • 3
  • 20
  • 34

3 Answers3

3

I would create an image context, then write both images into it. Then use UIImageWriteToSavedPhotosAlbum to save to album. Here is an example where I put a logo on the saved image when called from a button. In your case the brand image will be your overlay and the imageToSave will be the image from the UIImagePickerController. Modify to suit. Hopefully it will help:

 - (IBAction)saveImage:(id)sender{

    //add brand to image
    UIImage *BrandImage = [UIImage imageNamed:@"brand.png"];
    UIImage* imageToSave = [imageView image]; //get current imageView
    CGSize targetSize = CGSizeMake(self.imageView.image.size.width, self.imageView.image.size.height);
    CGRect imageRect = CGRectMake(0, 0, self.imageView.image.size.width, self.imageView.image.size.height);

    //get screen size for retina or non retina
    UIScreen *MainScreen = [UIScreen mainScreen];
    UIScreenMode *ScreenMode = [MainScreen currentMode];
    CGSize Size = [ScreenMode size];

//position brand logo according to screen size
    if (Size.width == 640) {
        topImageRect = CGRectMake(self.imageView.image.size.width - 160, self.imageView.image.size.height - 80, 141, 53);
    }
    else
    {
        topImageRect = CGRectMake(self.imageView.image.size.width - 80, self.imageView.image.size.height - 40, 71, 27);
    }


    UIGraphicsBeginImageContext(targetSize);
    CGContextRef context = UIGraphicsGetCurrentContext();       
    UIGraphicsPushContext(context);                             

    [imageToSave drawInRect:imageRect];
    [BrandImage drawInRect:topImageRect];

    UIGraphicsPopContext();                             

    // get a UIImage from the image context
    UIImage* SavedImage = UIGraphicsGetImageFromCurrentImageContext();

    // clean up drawing environment
    UIGraphicsEndImageContext();

    // Save it to the camera roll / saved photo album
    UIImageWriteToSavedPhotosAlbum(SavedImage, nil, nil, nil);

}
0

i think this may help to work with camera overlay view and saving overlay clicked image in to library http://red-glasses.com/index.php/tutorials/ios4-take-photos-with-live-video-preview-using-avfoundation/

B25Dec
  • 2,301
  • 5
  • 31
  • 54
  • Thanks for your reply.But i am using UIImagePickerController for capturing the photo.do have any idea on this instead of AVFoundation? – vinay Oct 14 '11 at 05:40
  • then you can try for this one too .http://idevhub.com/picking-images-with-the-iphone-sdk-uiimagepickercontroller/ – B25Dec Oct 14 '11 at 05:43
0

Sorry i didn't get your question earlier.. One way to do is that to capture the screenshot programmatically and then edit the image according to your requirements and save it.

This should help... How to take a screenshot programmatically

Community
  • 1
  • 1
Ankit Srivastava
  • 12,347
  • 11
  • 63
  • 115
  • Thanks for your answer.It will save only the captured image.But i want to save captured image with the overlay image. – vinay Oct 14 '11 at 06:11