iOS UIImage节省质量损失?

时间:2015-11-18 03:36:44

标签: ios objective-c uiimageview uiimage rendering

将UIImage保存到照片库时,我似乎失去了质量。任何想法如何解决它?这是重要的代码:

res.render({content: content});

这是imageWithView方法:

-(IBAction)aExportPhoto:(id)sender
{
UIImage *main = [self imageWithView:imageFrame];
UIImage *water = [self imageWithView:waterFrame];
UIImage *lign = [self imageWithView:lignFrame];

CGRect fMain = imageFrame.frame;
CGRect fWater = waterFrame.frame;
CGRect fLign = lignFrame.frame;

CGSize sMain = fMain.size;
CGSize sWater = fWater.size;
CGSize sLign = fLign.size;

UIGraphicsBeginImageContext(sMain);

[main drawInRect:CGRectMake(0, 0, sMain.width, sMain.height)];
[lign drawInRect:CGRectMake(fMain.origin.x, sMain.height - 25, sMain.width - 45, 20) blendMode:kCGBlendModeNormal alpha:1.0f];
[water drawInRect:CGRectMake(sMain.width - 45, sMain.height - 35, 40, 40) blendMode: kCGBlendModeNormal alpha: 1.0f];

UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIImageWriteToSavedPhotosAlbum(newImage, nil, nil, nil);
UIGraphicsEndImageContext();

}

提前致谢!

1 个答案:

答案 0 :(得分:0)

您应该UIGraphicsBeginImageContextWithOptions使用aExportPhoto,就像在imageWithView中一样。 UIGraphicsBeginImageContext使用1(非视网膜分辨率)的比例,并且您想要使用0(设备的比例)。