【问题标题】:Am I losing resolution after grabbing image of screen then cropping it?抓取屏幕图像然后裁剪后我会失去分辨率吗?
【发布时间】:2015-10-28 02:25:21
【问题描述】:

我有一些代码,我在其中抓取屏幕图像,然后根据一些边界值对其进行裁剪:

UIGraphicsBeginImageContextWithOptions(self.mainView.bounds.size, NO, 0.0);
[self.mainView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *comicImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

UIGraphicsBeginImageContextWithOptions(CGSizeMake(boundary.width, boundary.height), NO, 0.0);
[comicImage drawAtPoint:CGPointMake(-boundary.xMin, -boundary.yMin)];
comicImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

我想知道的是,我是否使用上述方法生成了低分辨率的低质量图像?有没有更好的方法来做到这一点?

【问题讨论】:

  • 我遇到了同样的问题。截屏并裁剪它总是使它质量很差。找不到其他选项。

标签: ios cocoa-touch uiimage


【解决方案1】:

也许,您可以使用以下代码

  UIGraphicsBeginImageContextWithOptions(size, NO, [UIScreen mainScreen].scale);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-06-27
    • 1970-01-01
    • 2012-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多