private static byte[] save(Bitmap src,Bitmap.CompressFormat format,int quality){
  ByteArrayOutputStream outputStream=null;
  try {
    outputStream=new ByteArrayOutputStream();
    src.compress(format,quality,outputStream);
    return outputStream.toByteArray();
  }
  finally {
    if (outputStream != null) {
      try {
        outputStream.close();
      }
 catch (      IOException e1) {
        e1.printStackTrace();
      }
    }
  }
}

private static byte [ ] save ( Bitmap src , Bitmap . CompressFormat format , int quality ) { ByteArrayOutputStream outputStream = null ; try { outputStream = new ByteArrayOutputStream ( ) ; src . compress ( format , quality , outputStream ) ; return outputStream . toByteArray ( ) ; } finally { if ( outputStream != null ) { try { outputStream . close ( ) ; } catch ( IOException e1 ) { e1 . printStackTrace ( ) ; } } } }
saving image to byte array
