gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 17:55:27 25 4
gpt4 key购买 nike

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

最佳答案

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 并在缓存中享受缩放后的位图。

关于android - 在缓存重新缩放的图像之前重新缩放在 Universal Image Loader 中下载的位图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19805900/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com