正在使用通用图像加载器来下载图像。这是我的配置和显示选项。直接获取位图而不是fileCacheUtil中的文件
File cacheDir = getApplicationContext().getCacheDir();
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
getApplicationContext())
.discCache(new UnlimitedDiscCache(cacheDir)).threadPoolSize(3)
.denyCacheImageMultipleSizesInMemory()
.tasksProcessingOrder(QueueProcessingType.LIFO)
.discCacheFileNameGenerator(new HashCodeFileNameGenerator())
.build();
options = new DisplayImageOptions.Builder()
.cacheOnDisc().bitmapConfig(Bitmap.Config.RGB_565)
.imageScaleType(ImageScaleType.EXACTLY).resetViewBeforeLoading()
.showStubImage(R.drawable.bt_fine_dining).build();
一切工作正常。但我想检查图像是否已经存在或没有。使用discCacheUtil能够获取图像文件。 [DiscCacheUtil.findInCache(imageUri,discCache)]。但有没有什么办法可以直接获取位图而不是文件?
而且,如果我同时指定cacheInMemory()和cacheOnDisc(),将图像保存两次?这里是否有额外的内存消耗,因为图像将被保存在内存和光盘中?请帮帮我。
在此先感谢
绘制但是,这很可能会重复,你已经做了DiscCacheUtil.findInCache。所以从文件加载更简单。 只要做 BitmapFactory.decodeStream(new FileInputStream(file)); – grebulon 2014-03-10 11:29:12