5

I have a question regarding the https://github.com/nostra13/Android-Universal-Image-Loader library.

I'm using imageLoader.displayImage(...) to load images from my database to imageviews, that are in a listview.

The docs say this:

ImageSize targetSize = new ImageSize(120, 80); // result Bitmap will be fit to this size
imageLoader.loadImage(imageUri, targetSize, displayOptions, new SimpleImageLoadingListener() {
    @Override
    public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
        // Do whatever you want with Bitmap
    }
});

Would it be possible to declare a target size for the imageLoader.displayImage method?

Tamas
  • 1,765
  • 1
  • 16
  • 26
  • There is not such possibility for `.displayImage(...)`. This size will be calculated from incoming `ImageView`considering its size and scale type. You can only specify scale type in `DisplayImageOptions`. Why do you want t0 declare target size for `displayImage(...)`? – nostra13 Jul 25 '13 at 14:08
  • because I'm using a custom imageview for upscaling images, and it's stuttering my ui. I always know in advance, what image sizes I will have, so I would like to just add that as an input, so I don't have to use the upscaleable imageview(which does the upscaling on the ui thread). – Tamas Jul 25 '13 at 14:20
  • Maybe `DisplayImageOptions.scaleType(ImageScaleType.NONE)` is what you need? Then ImageLoader won't scale original image. – nostra13 Jul 26 '13 at 19:55
  • Setting scaletype to none did not help. My 3rd party image upscale library still stutters the ui. I'm using this library btw: https://gist.github.com/tprochazka/5486822 – Tamas Jul 29 '13 at 08:10
  • also, with android 4.3, my 3rd party upscaling library is broken. :( – Tamas Aug 05 '13 at 10:13

2 Answers2

2

You can use method: public void loadImage(String uri, ImageSize targetImageSize, DisplayImageOptions options, ImageLoadingListener listener) to set a ImageSize parameter.

The downloaded image will be decoded and scaled to Bitmap of the size which is equal or larger (usually a bit larger) than incoming targetImageSize.

codezjx
  • 9,012
  • 5
  • 47
  • 57
0

What I'm currently using is that instead of setting the dimensions for the image using ImageLoader, I simply set the dimensions for the layout containing it with scaleType = centerCrop;

With that being said, I still suggest you switch to Picasso like @Vipul's answer instead. I encountered instabilities where images got messed up before the async request finished. This never happened with Picasso.

Hung Vu
  • 360
  • 3
  • 11