public static byte[] toBytes(Bitmap bmp){
  ByteArrayOutputStream stream=new ByteArrayOutputStream();
  bmp.compress(Bitmap.CompressFormat.PNG,100,stream);
  return stream.toByteArray();
}

public static byte [ ] toBytes ( Bitmap bmp ) { ByteArrayOutputStream stream = new ByteArrayOutputStream ( ) ; bmp . compress ( Bitmap . CompressFormat . PNG , 100 , stream ) ; return stream . toByteArray ( ) ; }
converts a given bitmap to byte array
