Reputation: 8486
I am trying to load a very large image from the internet in an android tablet application. I know how to load a smaller size sample but have noticed it hampers the resolution of the images. The android docs tell me about the BitmapRegionDecoder to help loading the images in tiles but there does not seem to be much documentation on it. I am doing something like this:-
BitmapRegionDecoder decoder = BitmapRegionDecoder.newInstance(inputstream, false);
I understand that i have to loop through the below code as many times as required to get the entire image by passing different rect objects
region = decoder.decodeRegion(new Rect(0, 0, 50, 50), null);
But i fail to understand how to put all these bits in the right position in one imageview. Any example would be really helpful
Upvotes: 1
Views: 3825
Reputation: 149
Yes you can use a BitmapRegionDecoder to view large Images based on Tiles
This guy here implemented a TileBitmapDrawable Class, that you can hook to your imageview:
https://github.com/diegocarloslima/ByakuGallery
Upvotes: 0
Reputation: 5410
What you are trying to do sounds like you want to defy the purpose of the region decoder. You could as well try to load the whole huge bitmap instead of pieces and joining them together. In the end you would risk an out of memory error either way. The point of the region decoder is getting just a clip from a huge bitmap. One use case could be a map view that can be panned with swipe gestures. You would calculate only the currently visible clip of the bitmap load that with the region decoder and display that in your map view. What you need to do is in fact loading a scaled version.
Upvotes: 0