Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. private static String bitmapToString(Bitmap bitmap) {
  2. ByteArrayOutputStream baos = new ByteArrayOutputStream();
  3. bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);
  4. byte[] b = baos.toByteArray();
  5. return Base64.encodeToString(b, Base64.DEFAULT);
  6. }
  7.  
  8. private static Bitmap stringToBitmap(String encodedString) {
  9. try {
  10. byte[] encodeByte = Base64.decode(encodedString, Base64.DEFAULT);
  11. return BitmapFactory.decodeByteArray(encodeByte, 0, encodeByte.length);
  12. } catch (Exception e) {
  13. e.getMessage();
  14. return null;
  15. }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement