Skip to content
Commitwise
Menu

Downsampling

Decoding an image at the smaller size it will be shown, instead of decoding the full image and shrinking it afterwards.

Definition

A decoded bitmap uses width × height × 4 bytes regardless of the file size, so a 12-megapixel photo takes about 48 MB in memory. Decoding directly at the displayed size (CGImageSourceCreateThumbnailAtIndex on iOS, ImageDecoder.setTargetSize or inSampleSize on Android) never allocates the full bitmap. Image libraries such as Coil, Glide, Kingfisher and Nuke downsample to the view's size automatically.

In practice

A 4000 × 3000 photo shown in a 120-point thumbnail on a 3× screen is decoded at 360 × 360, about 0.5 MB.

Related terms

Esc

Type to search the whole site.