October 2018
Intermediate to advanced
464 pages
15h 17m
English
The purpose of the loadSampledResource() method is to load a smaller image, to reduce the memory consumption of the image. If we attempted to load the original full-size image (see the previous Getting ready section), the app would require over 3 MB of RAM to load. That's more memory than most devices can handle (at the moment anyway), and even if it could be loaded completely, it would provide no visual benefit to our thumbnail view.
To avoid an Out of Memory situation, we use the inSampleSize property of BitmapFactory.Options to reduce, or subsample, the image. (If we set the inSampleSize=2, it will reduce the image by half. If we use inSampleSize=4, it will reduce the image by one quarter) To calculate inSampleSize, first, ...