I’m reading the source of Android Universal Image Loader.
I can’t understand what ImageScaleType.IN_SAMPLE_POWER_OF_2 means.
It says:“It’s fast type and it’s preferable for usage in lists/grids/galleries (and other AdapterView)”.
Why it’s fast and why it’s preferable for usage in adapterViews?
I’m not too sure about this, but I would assume that this enum value describes how many pixels (‘samples’) are taken, probably to calculate a single pixel of the output image.
The calculation would then typically take the average value of a number of source samples, like
newValue = (srcValue[1] + srcValue[2] + ... srcValue[n]) / n. And the division byncan be computed very fast if and whennis a power of 2 by bit-shifting integer values. Ifnis not a power of two a ‘real’ division operation is needed, which is computationally much more expensive.