Friday, 3 October 2008

Using Large Images with Android: A no-no

I want to be able to display satellite images not from Google, but from other sources on my Android GPS application.

I have already shown how to build a simple WMS client to display online satellite images. However, the use I envision for my device (which might not be a phone), is to be able to display such images offline, from the built-in disk or an SDCard.

The built-in BitmapFactory has not real support for larger images, anything over a certain size will just fail to load with a memory error.

I first thought that something like Java Advanced Imaging JAI will do the trick. Well, it would, were it not that all support for this has been disabled in Android, certainly to reduce the memory footprint and stop people doing stupid things, like processing large images.

Every other library then either uses java.awt's BufferedImage (again not available on Android) or JNI with some underlying C, C++ or whatever implementation.

So, this is all a dead end. I have thought for a long time, that there is room for a really light-weight WMS server implemented in Java, or something equally lightweight for image processing. A library that does NOT do everything, but just the bare minimals.

Now I have a new direction. As large files are really a no-no on Android, there has to be some preprocessing to make the files smaller.
Fortunately, there is gdal2tiles, a program from the GDAL Suite for geospatial processing. It turns a georeferenced file into a tree of much smaller ones together with an XML based description. Parsing the XML file will allow me to pick the tiles I need to put the overlay image back together.

Stay tuned.

No comments: