title: Filling the data in an Android bitmap as quickly as possible from C
body: <p>I've managed to get an android.graphics.Bitmap created and I'm successfully filling it via the SetPixels command.</p>
  
  <p>The problem is that I start off with RGBA data.  I then create a jintArray.  I then call SetIntArray (effectively memcpying the data into the buffer).  Then, finally, I call setPixels to actually set the pixels (which presumably causes another copy).</p>
  
  <p>one big issue with doing this is that whether I used R8G8B8A8 or R5G6B5 or A8 I still have to convert my pixel data to R8G8B8A8 data. </p>
  
  <p>Ideally I'd like a way to fill the buffer using only one copy and allow me to do it without doing the pixel format conversion.</p>
  
  <p>Is there any way to directly get at the buffer data contained in a Bitmap? I see there is a function GetDirectBufferAddress in the JNI, but the documentation I can find on it suggests its limited to a java.nio.buffer.  Can I directly get at the pixel data using this function? Perhaps by getting the internal buffer used by the Bitmap class?  </p>
  
  <p>Is my only way of using this to create a Global Ref'd Java.nio.buffer then each time I want to update, copy my pixel data into it and then use copyPixelsFromBuffer?  This still involves 2 copies but can, at least, eliminate the pixel format change.  Is this going to be any more efficient than the method I'm already using?   </p>
  
  <p>Is there an even better way of doing it?</p>
  
  <p>Btw, I <em>AM</em> aware of the fact I can use the functions in &lt; android/bitmap.h > but I would really like to not lose support for Android 2.1 and Android 2.2 ...</p>
  
  <p>Cheers in advance!</p>