保存来自摄像机的缩放图像

问题描述

| 我正在为iphone / ipad开发相机应用程序。 我们正在使用叠加层在取景器顶部显示相机应用程序。 目前,我正在尝试保存缩放的图像。我们能够在取景器上缩放图像。但是,当我们保存图像时,它将以原始大小保存。 为了解决这个问题,我们使用以下代码缩放缩放的图像:
UIImageView *v = [[UIImageView alloc]initWithImage:image];

UIGraphicsBeginImageContext(v.bounds.size);
CGContextRef context = UIGraphicsGetCurrentContext();

CGContextSaveGState(context);
CGContextScaleCTM(context,zoomvalue,zoomvalue);
[v drawRect:CGRectMake(0,320,480)];
CGContextRestoreGState(context);
image = UIGraphicsGetimageFromCurrentimageContext();
UIGraphicsEndImageContext();
使用上面的代码,我们可以获得放大的图像。 但是,我们需要裁剪缩放图像的中心部分并保存。我们不一样了。 请帮助     

解决方法

        如果您使用
UIImagePickerController
捕获图像并在那里进行缩放,则可以通过从选择器
NSDictionary
中获取getting2ѭ来获得编辑后的图像,如下所示-
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 
{

    img =  [[info objectForKey:UIImagePickerControllerEditedImage] retain];
    [picker dismissModalViewControllerAnimated:YES];

}