Skip to content

X. Picasso, Glide, Fresco

davemorrissey edited this page Nov 25, 2017 · 1 revision

Out of the box, SubsamplingScaleImageView is not compatible with most image loader libraries. This is because it requires a file saved in local storage to enable tiles to be read from the image as required. Additionally, the view doesn't extend ImageView for several reasons, but most importantly because it does not display a single bitmap, and cannot implement most of ImageView's methods or display vector graphics, 9-patches, XML drawables etc.

Most image loaders are designed to load an image file from some source, decode them into a Bitmap object, and pass that image to an ImageView. This will only work with images that are small enough to be fully decoded in memory, and smaller than the maximum texture size (usually 2048px or 4096px). This makes them incompatible with the intention of SubsamplingScaleImageView, which is to display images that are larger than the maximum texture size, and too large to be decoded at native resolution.

There are workarounds available.

Glide and Fresco

Piasy's BigImageViewer library provides a bridge between SSIV and Glide or Fresco.

Picasso

Picasso can be made to work with SubsamplingScaleImageView thanks to a custom decoder implementation written by @gokhanbarisaker. You will need to use OkHttp and make sure it is using a disk cache.

You should also call picasso.cancelTag(tagYouUsedInDecoderConstructor) when you are done with the image.

These custom decoders are not included in the project because they require Picasso and OkHttp. You can get the source from the Gist below, and follow the instructions on the custom decoders page to set them up.

https://gist.github.com/davemorrissey/e2781ba5b966c9e95539

Clone this wiki locally