【问题标题】:screenshot image taken on Ratina display looks blurred with 1.0 scale, and too big with 0.0 scale在 Retina 显示屏上拍摄的屏幕截图在 1.0 比例下看起来很模糊,在 0.0 比例下看起来太大
【发布时间】:2012-05-09 02:59:44
【问题描述】:

我正在使用以下代码截取我的一个视图控制器的屏幕截图,然后稍后在另一个视图中显示它。对于 UIGraphicsBeginImageContextWithOptions 方法,如果给它 1.0 作为比例,结果图像会看起来很模糊;但是如果给它 0.0 作为比例,结果图像会比屏幕大,并且在另一个视图中显示时可以看到它的一部分。有没有办法解决这个问题?

CGSize imageSize = [[UIScreen mainScreen] bounds].size;
if (NULL != UIGraphicsBeginImageContextWithOptions) {
    UIGraphicsBeginImageContextWithOptions(imageSize, NO, 1.0);
} else {
    UIGraphicsBeginImageContext(imageSize);
}

[_displayViewController.view.layer renderInContext:UIGraphicsGetCurrentContext()];

// Retrieve the screenshot image
UIImage *screenImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

【问题讨论】:

    标签: iphone uiimage blurry quartz-core


    【解决方案1】:

    其实如果我在使用

    UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0);
    

    图像看起来很清晰,但此屏幕截图仅涵盖屏幕上显示的内容,而不包括隐藏在屏幕外的内容。

    如果我将大小更改为 UIView 的大小,我也会遇到上述问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-12
      • 1970-01-01
      • 2021-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多