在缓存重新缩放的图像之前,重新缩放在Universal Image Loader中下载的位图

时间:2013-11-06 06:57:33

标签: android universal-image-loader

我正在使用Universal Image Loader在ImageView中显示位图。但是当下载位图时我想重新调整它,然后重新调整位图应该被缓存....我无法确定需要修改以实现我的目的的那一点。

1 个答案:

答案 0 :(得分:3)

UIL DisplayImageOptions有一个imageScaleType参数,需要ImageScaleTypeThe docs for ImageScaleType明确说明缩放是在图像缓存之前发生的:

/**
* 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.
*/

因此,在DisplayOptions中设置ImageScaleType并享受缓存中的缩放位图。