title: Faster way for Bitmap to Byte[] coversion
body: <p>I am not new to bitmaps nor new to java. I am trying to convert High resolution bitmaps to byte array in a loop. Please find code here:</p>
  
  <pre><code>ByteArrayOutputStream stream = new ByteArrayOutputStream();
  bitmap.compress(Bitmap.CompressFormat.JPEG, 50, stream);
  imageByteArray = stream.toByteArray();
  </code></pre>
  
  <p>When i am using the above approach I cam able to convert 5 images in 1 second. But I need it to be even faster. I tried <code>ByteBuffer</code> approach also like this:</p>
  
  <pre><code>Bitmap bmp = intent.getExtras().get("data");
  int size = bmp.getRowBytes() * bmp.getHeight();
  ByteBuffer b = ByteBuffer.allocate(size);
  
  bmp.copyPixelsToBuffer(b);
  
  byte[] bytes = new byte[size];
  
  try {
  b.get(bytes, 0, bytes.length);
  } catch (BufferUnderflowException e) {
  // always happens
  }
  </code></pre>
  
  <p><em>But this is very slow (Slower then previous) :(</em></p>
  
  <p><em>Please, can somebody give a faster method? Guide Me...</em></p>