This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static String bitmapToString(Bitmap bitmap) { | |
ByteArrayOutputStream baos = new ByteArrayOutputStream(); | |
bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos); | |
byte[] b = baos.toByteArray(); | |
return Base64.encodeToString(b, Base64.DEFAULT); | |
} | |
private static Bitmap stringToBitmap(String encodedString) { | |
try { | |
byte[] encodeByte = Base64.decode(encodedString, Base64.DEFAULT); | |
return BitmapFactory.decodeByteArray(encodeByte, 0, encodeByte.length); | |
} catch (Exception e) { | |
e.getMessage(); | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment