public static byte [ ] encodeBitmapToArray ( Bitmap bitmap , Bitmap . CompressFormat format ) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream ( ) ; bitmap . compress ( format , 0 , outputStream ) ; return outputStream . toByteArray ( ) ; }
Encodes a bitmap to a byte array .