UIGraphicsGetImageFromCurrentImageContext()Retina分辨率? [英] UIGraphicsGetImageFromCurrentImageContext() Retina resolution?
本文介绍了UIGraphicsGetImageFromCurrentImageContext()Retina分辨率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在拍照并使用 UIGraphicsGetImageFromCurrentImageContext()
来操作它。一切都工作很好。然而,在iPhone 4上,分辨率看起来很不舒服,因为它使用的图像似乎是标准分辨率,而不是@ 2x。是否有任何方法可以提高生成的图片的分辨率?
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage * image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
你应该使用 UIGraphicsBeginImageContextWithOptions
,它允许您设置缩放因子。使用比例因子0.0f可使用设备的比例因子。
I'm taking a picture of my screen and manipulating it by using UIGraphicsGetImageFromCurrentImageContext()
. Everything is working just fine. However, on an iPhone 4, the resolution looks pretty shabby as it seems like the image it uses is standard resolution, not @2x. Is there any way to increase the resolution of the resulting image?
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
解决方案 You should use UIGraphicsBeginImageContextWithOptions
which allows you to set the scale factor. Use a scale factor of 0.0f to use the device's scale factor.
这篇关于UIGraphicsGetImageFromCurrentImageContext()Retina分辨率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文