UIImage 调整大小 - scaleFactor 值是如何导出的尚不清楚

UIImage resizing - how scaleFactor value derived is unclear

这可能是个愚蠢的问题,但我看不出这里的数学原理。我有一张图片,414w x 584h。要使用 [UIImage imageWithCGImage:scaleFactor:orientation] 将图像缩小到此尺寸的一半(即初始宽度和高度的一半),我必须将 scaleFactor 设置为 6.0.

为什么是 6.0?这个值与 414/207 = 2.0 的宽度比例或相同值的高度比例 584/292 = 2.0 有什么关系?

在撰写本文时,我想知道...我的应用程序 运行 在 iPhone 6+ 上。那么它可能与 3x Retina 显示屏有关吗?即,正常比例因子 2.0,它是无量纲的,但是当应用于 6+ 上的图像时,为了达到像素,我必须做 3 倍吗?这是逻辑吗?

而且,我想,当我在这里时,有没有更好的方法来使用可用的 iOS 工具来调整图像大小?例如,一些特殊的仿射变换等?对内存或性能没有特别的担忧;图片的宽度都不超过 1000 x 1500 左右。

非常感谢!

您可以在 http://nshipster.com/image-resizing/

找到 grt 教程

文档说:

The scale factor to use when interpreting the image data. Specifying a scale factor of 1.0 results in an image whose size matches the pixel-based dimensions of the image. Applying a different scale factor changes the size of the image as reported by the size property.

比例:

If you load an image from a file whose name includes the @2x modifier, the scale is set to 2.0. You can also specify an explicit scale factor when initializing an image from a Core Graphics image. All other images are assumed to have a scale factor of 1.0.

If you multiply the logical size of the image (stored in the size property) by the value in this property, you get the dimensions of the image in pixels.

尺寸:

In iOS 4.0 and later, this value reflects the logical size of the image and is measured in points. In iOS 3.x and earlier, this value always reflects the dimensions of the image measured in pixels