Skip to content

Instantly share code, notes, and snippets.

@safaorhan
Created September 1, 2015 08:53
Show Gist options
  • Save safaorhan/26d7924b7a3a2aedd950 to your computer and use it in GitHub Desktop.
Save safaorhan/26d7924b7a3a2aedd950 to your computer and use it in GitHub Desktop.
Bitmap - String Conversion
public String encodeThumbnail(Bitmap bitmap) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
return Base64.encodeToString(stream.toByteArray(), Base64.DEFAULT);
}
private Bitmap decodeThumbnail(String thumbData) {
byte[] bytes = Base64.decode(thumbData, Base64.DEFAULT);
return BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment