Save Picture with Overlay

Greetings. I'm working on saving a picture taken with the camera to the camera with an overlay that is presented on top of the camera preview. Here's what I have so far...

    public override void FinishedPickingMedia(UIImagePickerController picker, NSDictionary info)
        var cameraImage = info[UIImagePickerController.OriginalImage] as UIImage;
        if (cameraImage != null)
            UIGraphics.BeginImageContext(new SizeF(UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height));
            var context = UIGraphics.GetCurrentContext();
            var menuBarUIOffset = 44.0f;
            cameraImage.Draw(new RectangleF(0, 0, UIScreen.MainScreen.Bounds.Width,
                                       UIScreen.MainScreen.Bounds.Height - menuBarUIOffset));
            RenderView(context, picker.View);
            var imgToSave = UIGraphics.GetImageFromCurrentImageContext();
            // var imgToSave = AddImageToImage(((UIImageView)picker.CameraOverlayView).Image, cameraImage);

            imgToSave.SaveToPhotosAlbum((img, error) =>
                    if (error != null)
                        Mvx.Error("Error Saving Photo");

                    picker.DismissViewController(true, null);


    private void RenderView(CGContext context, UIView view)
        context.TranslateCTM(view.Center.X, view.Center.Y);
        context.TranslateCTM(view.Bounds.Size.Width * (view.Layer.AnchorPoint.X), view.Bounds.Size.Height * (view.Layer.AnchorPoint.Y));

Here's what I see in my app when I capture a photo...

When I tap use to try and merge and save the captured photo with the overlay, I'm only getting the orignal image, as seen below..

As always, I sure appreciate the help!!


  • BlakeDavidsonBlakeDavidson USMember ✭✭

    Looks like the links to the images were messed up...

    Here's the first one.

    And the second one.

Sign In or Register to comment.