【问题标题】:Image decoding failed in Universal Image Loader通用图像加载器中的图像解码失败
【发布时间】:2014-08-31 17:46:59
【问题描述】:

我正在使用 Nostra 的通用图像加载器来显示图像。这是我要显示的图片的网址:

http://hitbullseye.com/ATTACHMENT/test6eac134c-81ae-4a47-ba28-f25dcc48718a.jpg

我在 logcat 中收到以下错误:

我不明白的一件事是为什么 UIL 在 url 末尾附加 _480x800。我检查了图像,它的尺寸是 248x72。这是我的代码:

我在其中创建配置的应用程序类:

public class BullsEyeApplicationGlobal extends Application {

@Override
public void onCreate() {
    super.onCreate();
    File cacheDir = StorageUtils.getCacheDirectory(getApplicationContext());
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
            getApplicationContext())
            .taskExecutor(null)
            .taskExecutorForCachedImages(null)
            .threadPoolSize(3)
            // default
            .threadPriority(Thread.NORM_PRIORITY - 1)
            // default
            .tasksProcessingOrder(QueueProcessingType.FIFO)
            // default
            .denyCacheImageMultipleSizesInMemory()
            .memoryCache(new LruMemoryCache(2 * 1024 * 1024))
            // default
            .discCache(new UnlimitedDiscCache(cacheDir))
            .imageDownloader(
                    new BaseImageDownloader(getApplicationContext())) // default
            .imageDecoder(new BaseImageDecoder(false)) // default
            .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) //
            .writeDebugLogs().build();
    ImageLoader.getInstance().init(config);
}

}

这里是我加载图片的地方:

ImageLoader imgL = ImageLoader.getInstance();
        DisplayImageOptions options = new DisplayImageOptions.Builder()
                .resetViewBeforeLoading(false) // default
                .cacheInMemory(true) // default
                .cacheOnDisc(true) // default
                .considerExifParams(false) // default
                .imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2) // default
                .bitmapConfig(Bitmap.Config.ARGB_8888) // default
                .build();
        ImageView imgg = (ImageView) v1.findViewById(R.id.test_image);
        imgL.displayImage(js.getString("TestImage"), imgg, options);

【问题讨论】:

  • UIL 不会在图像路径上附加任何内容。检查js.getString("TestImage") 添加附加文本的位置。
  • @intrepidkarthi 它的网址没有 _480x800,我已经检查过了。
  • 日志的第一行是http://hitbullseye.com/ATTACHMENT/_480x800。但是当图像出现时,图像名称被附加在两者之间。它正在您的代码中处理。只需在您的项目目录中进行字符串搜索 _480x800
  • @intrepidkarthi 我想这会消除你的疑虑 :) i.imgur.com/fUnoL9x.png
  • 尝试运行.imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2)属性

标签: android universal-image-loader


【解决方案1】:

这不是图书馆的问题。问题是图像是 CMYK - 8bit/channel - jpg 文件。它们应该是 RGB - 16 位/通道 - png 文件,以使它们可以在所有设备上工作。所以,问题出在图像上。我的问题现在已经解决了,希望对大家有帮助!

【讨论】:

  • 你应该接受你自己的答案,它对我也有帮助。谢谢:)
  • @yahya 好的,很高兴它有帮助:)
猜你喜欢
  • 2012-12-03
  • 2015-01-13
  • 1970-01-01
  • 2013-06-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-07
相关资源
最近更新 更多