title: Bitmap/Canvas use and the NDK
body: <p>I've recently found out that there is no hard limit to the amount of memory NDK code can allocate in contrast to the heavily limited amount of memory (~25Mb on most devices) you can allocate on the Java side.</p>
  
  <p>I want to write an image processing app (something like Photoshop) that needs to keep several large bitmaps in memory at once where the bitmap data will take ~20Mb of memory. Doing this in Java makes the app prone to out of memory exceptions on many devices I've tried.</p>
  
  <p>All my current code makes use of the Bitmap and Canvas class for doing my image manipulations. <strong>Can anyone suggest some way that allows me to allocate most of my memory on the C side and still make use of Bitmap+Canvas for performing my drawing operations (using Android 2.1 and above)?</strong></p>
  
  <p>As an example, if my image is composed of 6 bitmap layers and the user is painting on the 3rd layer, I need to draw a paint blob bitmap to the 3rd layer and then update the screen to show the result of flattening all layers on top of each other in real time. I've considered something along the lines of allocating my 6 bitmaps in C as int arrays and performing the painting operation on the Java side with Canvas using a copy of the layer being edited stored in a Bitmap object. I'm not sure how the flattening stage is going to work though.</p>