使用通用图像加载器加载的图像出现黑色背景

8
如下所示。第一张图片是默认图片,链接地址为http://goldentrail.towardstech.com/assets/images/membersimage/buttons/eat.png。而下面的第二张图片是使用uil加载的图片。
这是imageloader的配置。
    File cacheDir = StorageUtils.getCacheDirectory(context);
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
            .memoryCacheExtraOptions(480, 800) // default = device screen dimensions
            .discCacheExtraOptions(480, 800, CompressFormat.JPEG, 75)
            .taskExecutor(AsyncTask.THREAD_POOL_EXECUTOR)
            .taskExecutorForCachedImages(AsyncTask.THREAD_POOL_EXECUTOR)
            .threadPoolSize(3) // default
            .threadPriority(Thread.NORM_PRIORITY - 1) // default
            .tasksProcessingOrder(QueueProcessingType.FIFO) // default
            .denyCacheImageMultipleSizesInMemory()
            .memoryCache(new LruMemoryCache(2 * 1024 * 1024))
            .memoryCacheSize(2 * 1024 * 1024)
            .discCache(new UnlimitedDiscCache(cacheDir)) // default
            .discCacheSize(50 * 1024 * 1024)
            .discCacheFileCount(100)
            .discCacheFileNameGenerator(new HashCodeFileNameGenerator()) // default
            .imageDownloader(new BaseImageDownloader(context)) // default
            .imageDecoder(new BaseImageDecoder()) // default
            .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default
            .enableLogging()
            .build();

这是显示选项。

DisplayImageOptions options = new DisplayImageOptions.Builder()
    .bitmapConfig(Bitmap.Config.ARGB_8888) // default
    .cacheInMemory()
    .cacheOnDisc()

    .build();

enter image description here


你是否在ListView或GridView中显示图像??那么请在此处展示您的原始文件。 - krishna
2个回答

14

您是否在Readme中看到了注释:

DON'T COPY THIS CODE TO YOUR PROJECT! This is just example of ALL options using.

不要使用.discCacheExtraOptions(480, 800, CompressFormat.JPEG, 75)。 你的图片保存在磁盘缓存中,作为JPEG文件,无法具有透明背景。


如果您使用PNG格式,请尝试使用.discCacheExtraOptions(480, 800, CompressFormat.PNG, 75, null)之类的内容。否则请禁用缓存。 - Muz
抱歉,我忘记卸载应用程序了。它正在从缓存中获取图像。 - berserk
现在它已经被弃用了,有什么解决方法吗?(甚至在UIL中也没有CompressFormat类) - hkop

0

尝试使用android-query。这个API可以帮助处理图片和其他一些与Android相关的工作。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接