Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private String BitmapToString(Bitmap bitmap){
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
- byte[] b = baos.toByteArray();
- return Base64.encodeToString(b, Base64.DEFAULT);
- }
- public Bitmap StringToBitmap(String encodedString){
- try{
- byte[] encodeByte = Base64.decode(encodedString, Base64.DEFAULT);
- Bitmap bitmap = BitmapFactory.decodeByteArray(encodeByte, 0, encodeByte.length);
- return bitmap;
- } catch(Exception e){
- e.getMessage();
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment