【发布时间】:2015-08-13 13:37:09
【问题描述】:
Android-Universal-Image-Loader 能否将位图加载到按比例缩小的内存中,例如:http://developer.android.com/training/displaying-bitmaps/load-bitmap.html?
谢谢!
我正在加载这样的图像:
final ImageSize size = new ImageSize(MAX_W, MAX_H);
final DisplayImageOptions options = new DisplayImageOptions.Builder()
.imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2)
.build();
ImageLoader.getInstance().loadImage(uri.toString(), size, options, new ImageLoadingListener() { 我有两个问题:
- 生成的位图的高度或宽度通常大于 我指定的最大值。
- 我担心它会将整个位图加载到内存中并 只是按比例缩小,这将在低内存中出现大图像时失败 场景。
【问题讨论】:
-
“生成的位图的高度或宽度通常大于我指定的最大值”——您链接到的材料中的方法也是如此。除此之外,既然项目是开源的,为什么不look at the source and see for yourself if you can find a reference to
inSampleSize? -
“你链接到的材料中的方法也是如此”是真的。但是,可以更改比例因子计算来避免此问题。
-
“为什么不自己看源代码”我看了一眼,不清楚如何实现结果,所以我问。例如,您链接到的代码仅使用 inSampleSize。它没有显示如何在加载位图之前找到它的宽度/高度 - 计算 nSampleSize 应该是什么。
标签: android bitmap universal-image-loader