ios - 为什么矢量化 PDF 图像具有分辨率属性
问题描述
我有点困惑为什么矢量化图像具有分辨率属性?它不应该被矢量化并给你任何大小吗?
好的,我在 Xcode 上做了一个小测试,打印了一个 pdf 图像的宽度和高度。我注意到它的 3 乘以分辨率。(在 3 倍设备屏幕上测试)。
let imageRef = (imageView.image?.cgImage)!
let size = imageRef.bytesPerRow * imageRef.height
print(imageRef.width)
print(imageRef.height)
您可能知道,在编译时,Xcode 从 PDF 图像生成 1x、2x 和 3x 图像。这些图像大小由 Xcode 根据 PDF 图像的分辨率决定。这与测试结果相加。
我可以得出结论,pdf 图像需要在 1x 设备模板上具有像素大小的分辨率吗?生成的图像会被像素化吗?
此外,pdf 的分辨率不应高于所需的 1x 大小,否则可能会影响内存。正确的?
解决方案
It's simply a matter of how much work the asset catalog has to do in advance and how much work the system has to do at runtime. If your PDF is only for use at 1x, 2x, and 3x, the asset catalog can pre-render it when the app is built and so it takes no time at all for the runtime to draw it. But if you intend to show this PDF at other sizes, the runtime must perform that rendering. So you only preserve vector data in the latter case.
推荐阅读
- c# - 如何在主方法(控制台)中启动对象?
- ios - iOS后台模式下本地主机没有响应
- git - 将模板文件夹中的 git 钩子应用到特定的远程仓库
- kotlin - 使用纯 Kotlin 函数作为 Junit5 方法源
- powerbi - 如何按不同表中的列过滤表达式
- c# - IJS 互操作在 ASP.NET 3 剃须刀页面中不可用?
- r - 如何分析 R 包的加载
- powershell - 如何获取 AD 组中的嵌套组列表
- karate - 空手道 API:检查数字是否包含小数点
- python - 改进在 Python 3.7 标准环境中运行 Django 的 Google App Engine 的冷启动时间