What is the most memory-efficient way of downscaling images on iOS?

前端 未结 6 2091
后悔当初
后悔当初 2021-01-31 19:18

In background thread, my application needs to read images from disk, downscale them to the size of screen (1024x768 or 2048x1536) and save them back to disk. Original images are

6条回答
  •  感情败类
    2021-01-31 19:42

    With libjpeg-turbo you can use the scale_num and scale_denom fields of jpeg_decompress_struct, and it will decode only needed blocks of an image. It gave me 250 ms decoding+scaling time in background thread on 4S with 3264x2448 original image (from camera, image data placed in memory) to iPhone's display resolution. I guess it's OK for an image that large, but still not great.

    (And yes, that is memory efficient. You can decode and store the image almost line by line)

提交回复
热议问题