I'm intending to display very large Images in Android.
My first solution - to supply them as pdf - fails because not every handheld got a pdf-viewer preinstalled, and I don't want to require the users to install one.
So I have a png now (width = 3998px height=2827px) that I want to display. I downloaded this image to test how it would be displayed the gallery. It was quite painful. It seems that the galery renders this picture only once, and if I Zoom in, I cannot read the text at all.
So I wrote a testActivity which simply has an ImageView nested in a LinearLayout. I put the image into the drawable and set it as ImageView's image-source.
Unforunately the app crashes immediatly, due to an "
ERROR/AndroidRuntime(8906): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget"
I didn't expect that ONE single Image can be too large forVM's memory
. I played a little bit around, set ImageViews
size to 3998 & 2827px
, put the Image to sdCard
and read it manually with a fileInputStream
.
To my big surprise it now shows my image, but if I turn my Nexus S horizontal I get the same OutOfMemoryError
as before.
Can somewone point me the main difference between recieving a Bitmap through a FileInputStream
or to set it as ImageView's
source.
Also I'm not able to scroll comfortable with two parent scrollViews
I searching for a simple solution to display ONE large image
at a time with the ability to scroll horizontal and vertical
while able to zoom in and out.
here is a sample of the image I want to display
To handle scaling etc and using full resolution, You can use MapView of OSM (open street map) and provide it with your tiles (instead of the map). Check this: http://www.haakseth.com/?p=30