user2781627
user2781627

Reputation: 455

Rescaling bitmap downloaded in Universal Image Loader before caching rescaled images

I am using Universal Image Loader for displaying a bitmap in an ImageView. But when the bitmap is downloaded I want to rescale it and then that rescaled bitmap should be cached.... I am not able to identify that point at which modification is required to fulfill my purpose.

Upvotes: 1

Views: 1228

Answers (1)

blahdiblah
blahdiblah

Reputation: 34031

UIL DisplayImageOptions has an imageScaleType parameter which takes an ImageScaleType. The docs for ImageScaleType make clear that that scaling happens before the image is cached:

/**
* Image will scaled-down exactly to target size (scaled width or height or both
* will be equal to target size; depends on ImageView's scale type). Use it if
* memory economy is critically important.
* Note: If original image size is smaller than target size then original image
* won't be scaled.
* 
* NOTE: For creating result Bitmap (of exact size) additional Bitmap will be
* created with Bitmap#createBitmap(...)
* Cons: Saves memory by keeping smaller Bitmap in memory cache (comparing with
* IN_SAMPLE... scale types)
* Pros: Requires more memory in one time for creation of result Bitmap.
*/

So, set ImageScaleType in your DisplayOptions and enjoy the scaled bitmaps in your cache.

Upvotes: 3

Related Questions