Reputation: 28162
If we work with large images (bitmaps) we will hit a wall eventually in the size the image is allowed to be (in order to be displayed). I wondered if anyone knows where this limit is? There is many factors in this, the maximum heap size of the phone etc.
Also is there any workaround to handling large images if you want to display them and make them interact-able?
Upvotes: 1
Views: 13199
Reputation: 12367
If you already have decoded image data, you can store them in file on storage and then mmap this buffer.
Then you can create sub-images (tiles) over this buffer via createBitmap function
MMapped memory areas do not count agains heap, are not subject for garbage collection and are handled by paging subsystem bypassing usual file operations.
Upvotes: 2
Reputation: 6083
This article talks about working with large bitmaps and dealing with memory constraints. It also talks about a few factors that cause the OutOfMemoryErrors such as heap size, other bitmaps loaded into memory and memory fragmentation. Finally, it provides an algorithm to dynamically load the largest possible image file into memory and perform transforms.
http://bricolsoftconsulting.com/handling-large-images-on-android/
Upvotes: 0
Reputation: 13825
To compress large image size you can use
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 90, bytes);
Upvotes: 2
Reputation: 16082
If you want to display whole image fullscreen then delegate it to build-in application:
Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(uri, "image/jpeg");
startActivity(i);
When you want to display it as a thumbnail etc then read this doc.
Upvotes: 1