question: public static byte [ ] toByteArray ( Bitmap bitmap , Bitmap . CompressFormat format , int quality ) { ByteArrayOutputStream out = null ; try { out = new ByteArrayOutputStream ( ) ; bitmap . compress ( format , quality , out ) ; return out . toByteArray ( ) ; } finally { CloseableUtils . close ( out ) ; } }
target:  Compress the bitmap to the byte array as the specified format and quality.