1. /**
2.  * bitmap转为base64
3.  * @param bitmap
4.  * @return
5.  */  
6. public static String bitmapToBase64(Bitmap bitmap) {  
7.   
8. null;  
9. null;  
10. try {  
11. if (bitmap != null) {  
12. new ByteArrayOutputStream();  
13. 100, baos);  
14.   
15.             baos.flush();  
16.             baos.close();  
17.   
18. byte[] bitmapBytes = baos.toByteArray();  
19.             result = Base64.encodeToString(bitmapBytes, Base64.DEFAULT);  
20.         }  
21. catch (IOException e) {  
22.         e.printStackTrace();  
23. finally {  
24. try {  
25. if (baos != null) {  
26.                 baos.flush();  
27.                 baos.close();  
28.             }  
29. catch (IOException e) {  
30.             e.printStackTrace();  
31.         }  
32.     }  
33. return result;  
34. }  
35.   
36. /**
37.  * base64转为bitmap
38.  * @param base64Data
39.  * @return
40.  */  
41. public static Bitmap base64ToBitmap(String base64Data) {  
42. byte[] bytes = Base64.decode(base64Data, Base64.DEFAULT);  
43. return BitmapFactory.decodeByteArray(bytes, 0, bytes.length);  
44. }