我可以从图库中选择图像,然后裁剪图像,但质量太低了。
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();
请任何人帮我解决这个问题。
答案 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
渲染图像。 signView
是UIView
的对象。
主要关注的是,使用UIGraphicsBeginImageContextWithOptions
代替UIGraphicsBeginImageContext
。