OGeek|极客世界-中国程序员成长平台

标题: ios - 抓取屏幕图像然后裁剪后我会失去分辨率吗? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 11:37
标题: ios - 抓取屏幕图像然后裁剪后我会失去分辨率吗?

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

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();

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



Best Answer-推荐答案


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

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

关于ios - 抓取屏幕图像然后裁剪后我会失去分辨率吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33381889/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4