从图像上下文获取后,UIImageWriteToSavedPhotosAlbum以错误的图像大小保存

时间:2014-08-29 08:38:22

标签: ios uiimagepickercontroller

我试图用UIImagePickerController拍摄图像后保存图像+叠加:

// Crop a Combined Image from the taken picture - in order to remove the bottom bar
CGRect rect = CGRectMake(0,
                         0, 
                         [[UIScreen mainScreen] bounds].size.width,
                         [[UIScreen mainScreen] bounds].size.height - bottomBar.size.height);

UIGraphicsBeginImageContextWithOptions(rect.size,
                                       YES,
                                       0.0f);


// Render both images, the captured one from the camera and the UIImageView that is over that picture
[self.chosenImageView.layer renderInContext:UIGraphicsGetCurrentContext()];
[self.coverImageView.layer renderInContext:UIGraphicsGetCurrentContext()];

self.combinedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

现在,当我检查合并图像大小时,它是(320,470),这正是我所期望的。

当我使用以下内容保存到相册时:

UIImageWriteToSavedPhotosAlbum(self.combinedImage, self, @selector(thisImage:hasBeenSavedInPhotoAlbumWithError:usingContextInfo:), nil);

图像以全屏模式显示在相册中并拉伸(高度为iOS设备高度)。 最意想不到的是,当我定义高度小于440的上下文矩形时,图像会正确保存到相册而不会失真。一旦超过这个高度,就会强制全屏。

0 个答案:

没有答案