bitmap与字符串的相互转换 桃扇骨 2022-05-24 05:55 273阅读 0赞 Bitmap to String: public String BitMapToString(Bitmap bitmap)\{ ByteArrayOutputStream baos=new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG,100, baos); byte \[\] arr=baos.toByteArray(); String result=Base64.encodeToString(arr, Base64.DEFAULT); return result; \} String to Bitmap: public Bitmap StringToBitMap(String image)\{ try\{ byte \[\] encodeByte=Base64.decode(image,Base64.DEFAULT); Bitmap bitmap=BitmapFactory.decodeByteArray(encodeByte, 0, encodeByte.length); return bitmap; \}catch(Exception e)\{ e.getMessage(); return null; \} \}
还没有评论,来说两句吧...