Why does BitmapFactory.decodeByteArray return null?

后端 未结 7 860
失恋的感觉
失恋的感觉 2020-11-28 16:02

It\'s the simple code and instead of getting result to set the Bitmap, I get null. Can anyone tell me where I am making a mistake?

String test = \"test\";
by         


        
7条回答
  •  孤城傲影
    2020-11-28 16:32

    In such case you need to convert the string to Base64 first.

    String strImage = geTImageAsHexString();
    byte[] x = Base64.decode(strImage, Base64.DEFAULT);  //convert from base64 to byte array
    Bitmap bmp = BitmapFactory.decodeByteArray(x,0,x.length);
    

提交回复
热议问题