1

Can someone point me in the right direction. I've been searching around for this, but can't seem to find a clear answer. I have a UIScrollview thats 300x300 pixels. Inside that I have an UIImageView. The idea is to allow a user to grab a photo from their library, then pinch and zoom it within the 300x300 scrollview. Then save the view port as a new photo.

So far I have this...

    -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {

    UIImageView *insideImgView = [[UIImageView alloc] initWithImage:image];
    scroller.contentSize = CGSizeMake(image.size.width, image.size.height);
    scroller.maximumZoomScale = 4.0;
    scroller.minimumZoomScale = 0.0;
    scroller.clipsToBounds = YES;
    scroller.delegate = self;
    [self setSendImage:insideImgView];
    [scroller addSubview:insideImgView];
}

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
    return sendImage;
}

This works fine. I can pull the image in and pinch and zoom. But now how do i get the zoom and coordinates to slice up the photo when the they are done?

j0k
  • 22,600
  • 28
  • 79
  • 90
Mike Jaffe
  • 562
  • 2
  • 5
  • 13
  • Using your own gestures inside the image view would be better – Otium Apr 05 '12 at 00:00
  • Thanks, Otium. I think you might be right. Tried using gestures right on the UIImage view. Works great. Thanks. – Mike Jaffe Apr 05 '12 at 03:01
  • So I've got the pinch/zoom directly on the UIImageView now. But I'm still not clear on how to save the current zoom/move state? Is there a "one shot" way with UIImageView? Or do I need get coordinates, zoom ratio..etc? – Mike Jaffe Apr 05 '12 at 16:38
  • Capture a snapshot of the UIImageView using CoreGraphics – Otium Apr 05 '12 at 19:12
  • hi @MikeJaffe I need exactly same thing. How did you end up solving your problem? – BObereder Feb 09 '13 at 19:24
  • I used this solution. Worked perfectly. http://codefuel.wordpress.com/2011/04/22/image-cropping-from-a-uiscrollview/ – Mike Jaffe Feb 10 '13 at 02:10

1 Answers1

1

Exporting a view's content into an image is pretty simple.

Try using the answer by St3fan in this post: Get a PDF/PNG as output from a UIWebView or UIView.

Community
  • 1
  • 1
Bojan Dimovski
  • 1,216
  • 11
  • 25