public static String bitmapToBase64Str(Bitmap bitmap) {
if(bitmap == null) {
return null;
}
final PNGEncodedImage pngImage = PNGEncodedImage.encode(bitmap);
final byte[] pngData = pngImage.getData();
try {
final byte[] base64PngData = Base64OutputStream.encode(pngData, 0, pngData.length, false, false);
return "data:image/png;base64," + new String(base64PngData, "UTF-8");
} catch(Exception e) {
return null;