显示大图像时无法解码图像

时间:2013-09-27 08:48:42

标签: android android-image universal-image-loader

我无法在Universal Image Loader中加载大图片。

我的代码

ImageLoader imageLoader = null;
    try {
        File cacheDir = StorageUtils.getOwnCacheDirectory(this, Environment
                .getExternalStorageDirectory().getAbsolutePath());

        DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
                .cacheOnDisc().imageScaleType(ImageScaleType.EXACTLY)
                .bitmapConfig(Bitmap.Config.RGB_565).build();
        ImageLoaderConfiguration.Builder builder = new ImageLoaderConfiguration.Builder(
                this).defaultDisplayImageOptions(defaultOptions)
                .discCache(new UnlimitedDiscCache(cacheDir))
                .memoryCache(new WeakMemoryCache());

        ImageLoaderConfiguration config = builder.build();
        imageLoader = ImageLoader.getInstance();
        imageLoader.init(config);

    } catch (Exception e) {
        e.printStackTrace();
    }

    ImageView imageView1 = (ImageView) findViewById(R.id.imageView1);
    imageLoader
            .displayImage(
                    "http://www.kenrockwell.com/canon/lenses/images/100mm/IMG_1906.JPG",
                    imageView1, new ImageLoadingListener() {

                        @Override
                        public void onLoadingStarted(String arg0, View arg1) {
                            // TODO Auto-generated method stub
                        }

                        @Override
                        public void onLoadingFailed(String arg0, View arg1,
                                FailReason arg2) {
                            Log.e("", "" + arg2);

                        }

                        @Override
                        public void onLoadingComplete(String arg0,
                                View arg1, Bitmap arg2) {
                        }

                        @Override
                        public void onLoadingCancelled(String arg0,
                                View arg1) {
                        }
                    });

我收到这样的错误

09-27 14:13:00.982: E/ImageLoader(31251): Image can't be decoded [http://www.kenrockwell.com/canon/lenses/images/100mm/IMG_1906.JPG_1080x1920]

我能够加载其他图像只有这个图像无法加载。可能它的大小超过5 MB。那么如何使用UIL加载大图像。有没有其他方法来解决这个问题?

1 个答案:

答案 0 :(得分:-3)