0
votes

Can Android-Universal-Image-Loader load bitmaps into memory scaled down, like this: http://developer.android.com/training/displaying-bitmaps/load-bitmap.html ?

Thanks!

I'm loading images like this:

final ImageSize size = new ImageSize(MAX_W, MAX_H);
final DisplayImageOptions options = new DisplayImageOptions.Builder()
    .imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2)
    .build();

ImageLoader.getInstance().loadImage(uri.toString(), size, options, new ImageLoadingListener() { And I have two issues:

  1. The resulting bitmap often has a height or width greater than the max I specified.
  2. I worry it loaded the entire bitmap into memory and just scaled it down, which will fail with large images in low memory scenarios.
1
"The resulting bitmap often has a height or width greater than the max I specified" -- so will the approach in the material that you linked to. Beyond that, since the project is open source, why not look at the source and see for yourself if you can find a reference to inSampleSize? - CommonsWare
"So will the approach in the material you linked to" true. However one can change the scaling factor calculation to avoid this problem. - Alex Black
"why not look at the source yourself" I took a peek and its not clear to me how to achieve the result, so I asked. For example, the code you linked to merely uses the inSampleSize. It doesn't show how to find the width/height of the bitmap before loading it - to calculate what nSampleSize should be. - Alex Black

1 Answers

0
votes

Picasso can, and incase it a very large image.

                Picasso.with(getActivity().getBaseContext())
                    .load(new File(picturePath))
                    .resize(300, 400)
                    .placeholder(R.drawable.placeholder)
                    .error(R.drawable.errorimage)
                    .into(imageview);