Created
January 9, 2017 07:49
-
-
Save h4h13/f0f2dc4e460e1766b1720de8c7db175c to your computer and use it in GitHub Desktop.
Converters
This file contains hidden or 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
public static String encodeBitmapTobase64(Bitmap image) { | |
Bitmap immage = image; | |
ByteArrayOutputStream baos = new ByteArrayOutputStream(); | |
immage.compress(CompressFormat.PNG, 100, baos); | |
String imageEncoded = Base64.encodeToString(baos.toByteArray(), 0); | |
Log.d("Image Log:", imageEncoded); | |
return imageEncoded; | |
} | |
public static Bitmap decodeBase64ToBitmap(String input) { | |
byte[] decodedByte = Base64.decode(input, 0); | |
return BitmapFactory.decodeByteArray(decodedByte, 0, decodedByte.length); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment