尝试读取已解码的Base64 jpeg时,Android Bitmap工厂返回null

Gro*_*ppe 3 base64 android jpeg bitmap

我使用HTTP GET调用从Web服务检索了一个jpeg图像,我需要在ImageView中显示它,但它在Base64中编码.因此,我使用以下代码进行转换:

byte[] bytes = Base64.decode(imageStringInBase64, Base64.DEFAULT);
Bitmap bmp = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
Run Code Online (Sandbox Code Playgroud)

但是,我收到错误: --- SkImageDecoder::Factory returned null

登录到控制台后,imageStringInBase64如下所示:

data:image/jpeg;base64,/9j/4AAQ ... a bunch of stuff ... /B6TTbssco
Run Code Online (Sandbox Code Playgroud)

dmo*_*mon 5

如果data:image...是那么值imageStringInBase64不起作用.您只需要base64编码数据(最后一个逗号后面的所有内容).