I am trying to build an Android application which can take several photos taken by the camera, and merge them into one giant image. For example, I might take three photos and arrange them in a vertical stack for output as a single image. Ideally, I'd like to be able to keep the images at the original size. Unfortunately, using Bitmap.createBitmap() causes an OutOfMemoryException before even approaching the size of one photo of camera dimensions. Is this possible? Or do I just need to resort to scaling the photos before trying to merge them into a single Bitmap?
+3
A:
What is your goal?
If your goal is to upload the combined image, have the server combine them, since it has a wee bit more CPU and RAM than do most Android devices.
If your goal is to display the combined image, since each piece of the combined image is going to be bigger than the screen size, treat the image pieces as tiles -- don't combine them, but draw them as needed as the user scrolls around the virtual combined image space.
CommonsWare
2010-08-10 20:58:24
The specific goal is to combine the images into one then share via the normal share operation. This might involve posting to Twitter, emailing, or even just saving the combined picture. The project began due to not wanting to upload and link to several photos or create a photo set (on flickr, for example) when sharing photos. There is no server for this application.Your tip regarding on-screen display is spot on to what we intend to do.
nEx.Software
2010-08-10 21:11:14
@nEx.Software: "The specific goal is to combine the images into one then share via the normal share operation." -- I think you're in a world of hurt, then. Maybe there's a low-RAM third-party library that can work on JPEG files and stitch them together, possibly in C/C++ using the NDK. `BitmapFactory` and `Bitmap` want to have the images in RAM, which you don't need in this case and can't afford in any case.
CommonsWare
2010-08-10 21:35:02
I was afraid you were going to say that. Thanks for the insightful answer.
nEx.Software
2010-08-12 13:01:43