public static byte[] toByteArray(Bitmap bitmap){
  ByteArrayOutputStream outputStream=new ByteArrayOutputStream();
  bitmap.compress(Bitmap.CompressFormat.PNG,0,outputStream);
  return outputStream.toByteArray();
}

public static byte [ ] toByteArray ( Bitmap bitmap ) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream ( ) ; bitmap . compress ( Bitmap . CompressFormat . PNG , 0 , outputStream ) ; return outputStream . toByteArray ( ) ; }
copies a bitmap ' s pixels to a byte array .
