Can bitmap picture and Base64 string to convert to each other ~ henceforth mother no longer have to worry about me to deal with bitmap ~
/**
* Convert Bitmap to Base64 string
*
* @param bitmap
* @return Base64 string
*/
Public String bitmaptostring (Bitmap Bitmap, int bitmapquality) {
Convert Bitmap to String
string string = null;
Bytearrayoutputstream Bstream = new Bytearrayoutputstream ();
Bitmap.compress (Compressformat.png, bitmapquality, Bstream);
byte[] bytes = Bstream.tobytearray ();
String = base64.encodetostring (bytes, base64.default);
return string;
}
/**
* Convert base64 to bitmap picture
*
* @param string Base64 strings
* @return Bitmap
*/
Public Bitmap Stringtobitmap (string string) {
Converts a string to a bitmap type
Bitmap Bitmap = null;
try {
Byte[] Bitmaparray;
Bitmaparray = Base64.decode (string, base64.default);
Bitmap = Bitmapfactory.decodebytearray (Bitmaparray, 0,
Bitmaparray.length);
catch (Exception e) {
E.printstacktrace ();
}
return bitmap;
}