Skip to content

A Cocoapod to help with rendering bigger images, keeping the memory low and the FPS high.

License

Notifications You must be signed in to change notification settings

jonhocking/SmoothImageLoading

Repository files navigation

#Smooth Image Loading

This is a set of UIImage and UIImageView categories to help you load images in smoothly, and to help you hit that 60FPS mark.

It's specifically designed for large images that you've downloaded and need to display at a smaller size.

You should use this if:

  • You're seeing 'the pop' when your images scroll into view
  • You're displaying large images at a smaller frame size
  • You keep getting memory warnings because of your image usage

Features

  • Background thread image decompression
  • Lightweight caching based on filename
  • Lighter the memory footprint of images

Installation

The best way to install this is via cocoapods

Just add SmoothImageLoading to your pod file and you're away.

Why is the memory usage so much lower?

I use the ImageIO framework to render large images out at the exact size needed. This is a lot different to the usual Core Animation scaling you get when setting a big image in a small frame.

The big upshot of this comes when you're scrolling or animating the images as you no longer have to shift around and dump wasted pixels and memory with every frame.

What kind of benefits can I expect to see?

As an example, I was able to take a 5000x2500 image, rendered at 320x160, and improve the FPS from 2 to 60 in a table view of 100 images. The memory usage went from ~300mb to 10.5mb (caching off, 22mb with caching enabled).

Both of these are big improvements :)

If you want to talk to me about any of this then hit me up on Twitter - I'm @jonhocking

About

A Cocoapod to help with rendering bigger images, keeping the memory low and the FPS high.

Resources

License

Stars

Watchers

Forks

Packages

No packages published