Android : How to convert a image into base64Binary ?

 

imageView.buildDrawingCache();
Bitmap bitmap = profile_image.getDrawingCache();
String encodedImageData = getEncoded64ImageStringFromBitmap(bitmap);

============

public String getEncoded64ImageStringFromBitmap(Bitmap bitmap) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(CompressFormat.JPEG, 70, stream);
byte[] byteFormat = stream.toByteArray();
// get the base 64 string
String imgString = Base64.encodeToString(byteFormat, Base64.NO_WRAP);

return imgString;
}
(Visited 71 times, 1 visits today)
Spread the love