Save zoomed image from camera
I am developing a camera application for iphone/ipad. We are using an overlay for displaying the camera app on top of the viewfinder. Currently i am trying to save the zoomed image. We are able to zoom the image on viewfinder. But when we save the image it gets saved in the original size. To solve this we are scaling the zoomed image using the following code :
UIImageView *v = [[UIImageView alloc]initWithImage:image];
UIGraphicsBeginImageContext(v.bounds.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
CGContextScaleCTM(context, zoomvalue,zoomvalue);
[v drawRect:CGRectMake(0,0,320,480)];
CGContextRestoreGState(context);
image = UIGraphicsGetImageFromCurrentImageConte开发者_Go百科xt();
UIGraphicsEndImageContext();
Using the above code we are able to get the zoomed image. However, we need to crop the center portion of the scaled image and save the same. We are not getting the same.
Kindly help
if You are using UIImagePickerController
to capture image and zoom your image there then you can get the edited image by getting UIImagePickerControllerEditedImage
from picker NSDictionary
something like this -
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
img = [[info objectForKey:UIImagePickerControllerEditedImage] retain];
[picker dismissModalViewControllerAnimated:YES];
}
精彩评论