title: android fast pixel access and manipulation
body: <p>I'm trying to port an emulator that i have written in java to android. Things have been going nicely, I was able to port most of my codes with minor changes however due to how emulation works, I need to render image at pixel level.</p>
  
  <p>As for desktop java I use  </p>
  
  <pre><code>int[] pixelsA = ((DataBufferInt) src.getRaster().getDataBuffer()).getData(); 
  </code></pre>
  
  <p>which allow me to get the reference to the pixel buffer and update it on the fly(minimize object creations)</p>
  
  <p>Currently this is what my emulator for android does for every frame</p>
  
  <pre><code>@Override
  public void onDraw(Canvas canvas)
  {
      buffer = Bitmap.createBitmap(pixelsA, 256, 192, Bitmap.Config.RGB_565);
      canvas.drawBitmap(buffer, 0, 0, null);
  
  }   
  </code></pre>
  
  <p>pixelsA is an array int[], pixelsA contains all the colour informations, so every frame it will have to create a bitmap object by doing</p>
  
  <pre><code>buffer = Bitmap.createBitmap(pixelsA, 256, 192, Bitmap.Config.RGB_565);
  </code></pre>
  
  <p>which I believe is quite expensive and slow.</p>
  
  <p>Is there any way to draw pixels efficiently with canvas?</p>