我想捕获图像中的当前屏幕。我这样做:UIGraphicsBeginImageContext不返回视网膜图像
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.isOpaque, UIScreen.main.scale)
self.view.drawHierarchy(in: self.view.bounds, afterScreenUpdates: false)
let snapshot = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
问题是规模参数。如果我理解正确,0.0代表非视网膜,2.0代表视网膜,3.0代表6加和7加视网膜。无论我输入到scale参数中,输出始终是375x667分辨率的图像。我也尝试了不同的方法:
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.isOpaque, UIScreen.main.scale)
self.view.layer.render(in: UIGraphicsGetCurrentContext()!)
let snapshot: UIImage? = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
同样的情况。我甚至使用
UIScreen.main.scale
这实际上回报价值2.0。我究竟做错了什么?我如何获得更高分辨率的图像?
实际上,0.0表示实际的屏幕比例,而不是非视网膜。那是1.0。 – the4kman
你如何确定最终图像的“大小”? –
“分辨率”是什么意思?唯一不同的是UIImage的“scale”。尺寸以点为单位,而不是像素;所有的比例都是一样的。 – matt