Resizing Large Resolution Images Producing 1000x1000 Pixels Size when Size is set to 500x500 Pixels

左心房为你撑大大i 提交于 2019-12-02 13:24:23

The problem is that you are not taking into account the scale of the image you're creating.

You have a Retina screen. When you call lockFocus and draw into the resulting graphics context, the graphics context has double-resolution. Thus, a size of 500x500 results in an underlying bitmap of 1000x1000. That doesn't matter for purposes of display; to the extent that it does matter, it's a good thing.

But when you proceed to save the image data to disk, you throw away the knowledge that this is a double-resolution image, and you simply save the bitmap — which is 1000x1000.

You should look at Apple's documentation on how to deal with high-resolution images, e.g. https://developer.apple.com/library/content/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/APIs/APIs.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!