Why does this code decompress a UIImage so much better than the naive approach?

后端 未结 1 2028
名媛妹妹
名媛妹妹 2021-02-06 02:59

In my app I need to load large JPEG images and display them in a scroll view. In order to keep the UI responsive, I decided to load the images in the background, then display th

相关标签:
1条回答
  • 2021-02-06 03:44

    I assume that you're running this on a Retina device. In UIGraphicsBeginImageContextWithOptions, you asked for the default scale, which is the scale of the main screen, which is 2. This means that it's generating a bitmap 4x as large. In the second function, you're drawing at 1x scale.

    Try passing a scale of 1 to UIGraphicsBeginImageContextWithOptions and see if your performance is similar.

    0 讨论(0)
提交回复
热议问题