选择图像和裁剪图像成为低质量的iOS

时间:2016-06-02 03:49:58

标签: ios objective-c uiimage

我可以从图库中选择图像,然后裁剪图像,但质量太低了。

CGRect value=  AVMakeRectWithAspectRatioInsideRect(imageView.image.size, imageView.frame);
UIGraphicsBeginImageContext(imageView.image.size);
[imageView.image drawInRect:CGRectMake(0,0, value.size.width, value.size.height)];
UIImage *img= UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

请任何人帮我解决这个问题。

2 个答案:

答案 0 :(得分:0)

您需要使用UIGraphicsBeginImageContextWithOptions创建上下文,并以0为单位传递。调用UIGraphicsBeginImageContext不允许使用视网膜图像。

答案 1 :(得分:0)

以下是我在我的一个项目中所做的事情:

   //*************** This one creates blury image so used contextWith options *****************************//

   // UIGraphicsBeginImageContext(CGSizeMake(signView.bounds.size.width, signView.bounds.size.height));

    UIGraphicsBeginImageContextWithOptions(signView.bounds.size, signView.opaque, 0.0);

    [signView.layer renderInContext: UIGraphicsGetCurrentContext()];
    // UIImage *imgMySignature = UIGraphicsGetImageFromCurrentImageContext();
    signView.img = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

我在这里从UIView渲染图像。 signViewUIView的对象。

主要关注的是,使用UIGraphicsBeginImageContextWithOptions代替UIGraphicsBeginImageContext