Bitmap from String

前端 未结 3 502
情歌与酒
情歌与酒 2021-01-20 21:13

Is there a way or How do I take a String and create a bitmap from it using Java for development for Android?

I had a look at the java api for bitmaps and couldnt fin

3条回答
  •  一整个雨季
    2021-01-20 22:09

    You can use the decodebytearray method of bitmap factory like

    byte[] imageAsBytes = Base64.decode(myImageData.getBytes());
    Bitmap bp = BitmapFactory.decodeByteArray(imageAsBytes, 0, imageAsBytes.length);
    

    Where myImageData is a base64 string.

    If you have an array just pass that to the decodeByteArray method.

提交回复
热议问题