/* bitmap code use in main activity*/
Bitmap profileimage = BitmapFactory.decodeFile(you image path here);
String basestring=convert(bitmapConvert)
|
/*converting the base64 string to bitmap */
public Bitmap convert(String base64Str) throws IllegalArgumentException {
byte[] decodedBytes = Base64.decode(
base64Str.substring(base64Str.indexOf(",") + 1),
Base64.DEFAULT );
return BitmapFactory.decodeByteArray(decodedBytes, 0, decodedBytes.length);
}
|
/*converting the bitmap image to string in base64*/
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 70, outputStream);
return Base64.encodeToString(outputStream.toByteArray(), Base64.DEFAULT);
}
|