I am creating a giant image viewer, when I try to download a 15MB image here to see her
As an image viewer I use Subsampling Scale Image View which is optimized for displaying large images.
final SubsamplingScaleImageView imageView = (SubsamplingScaleImageView) view.findViewById(R.id.iv_photo);
...
Glide.with(view.getContext())
.load(srcImage).asBitmap()
.format(DecodeFormat.PREFER_ARGB_8888)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.error(R.drawable.error_image_load)
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
progressBar.setVisibility(View.GONE);
imageView.setImage(ImageSource.bitmap(resource));
}
});
I returned a
GLIDE Caused by: java.lang.OutOfMemoryError: Failed to allocate to 96000012 byte allocation with 15189568 free bytes and 74MB until OOM
The funny thing is that if I charge it to a normal imageView
I do not skip the error, I guess as the imageView
can not be enlarged, Glide must eliminate the giant's memory and only a copy to the size of imageView
Glide.with(getActivity())
.load(srcImage)
.thumbnail(0.1f)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.error(R.drawable.error_image_load)
.crossFade(1000)
.into(imageView);
Any suggestions to solve that OutOfMemory
?