public static String toBase64(Bitmap bitmap){
  if (bitmap == null) {
    throw new NullPointerException("Bitmap cannot be null");
  }
  String base64Bitmap=null;
  ByteArrayOutputStream stream=new ByteArrayOutputStream();
  bitmap.compress(Bitmap.CompressFormat.PNG,100,stream);
  byte[] imageBitmap=stream.toByteArray();
  base64Bitmap=Base64.encodeToString(imageBitmap,Base64.DEFAULT);
  return base64Bitmap;
}

public static String toBase64 ( Bitmap bitmap ) { if ( bitmap == null ) { throw new NullPointerException ( "Bitmap cannot be null" ) ; } String base64Bitmap = null ; ByteArrayOutputStream stream = new ByteArrayOutputStream ( ) ; bitmap . compress ( Bitmap . CompressFormat . PNG , 100 , stream ) ; byte [ ] imageBitmap = stream . toByteArray ( ) ; base64Bitmap = Base64 . encodeToString ( imageBitmap , Base64 . DEFAULT ) ; return base64Bitmap ; }
serializes the bitmap to base64
