0

我已将位图编码为字符串 Base64,并将其存储在 mysql 数据库中。然后我检索了这些信息,并试图从中重建一个位图。

blob 的值不为 null 并且在 base64 中。好吧,它似乎在base64中。当我这样做时

//This has the encoded string 
String encodedString = intervention.getUser_sign()

byte[] decodedUserString = Base64.decode(intervention.getUser_sign(), Base64.NO_WRAP);
Bitmap decoded_user_sign = BitmapFactory.decodeByteArray(decodedUserString, 0, decodedUserString.length);
user_sign.setImageBitmap(decoded_user_sign);

decoded_user_sign 为“空”。

在 logcat 中,我拥有的唯一信息是:

DEBUG/skia(31358): --- SkImageDecoder::Factory returned null   

这是编码的代码:

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        b.compress(Bitmap.CompressFormat.PNG,50,baos);
        byte[] bytes=baos.toByteArray();
        String base64Image = Base64.encodeToString(bytes,Base64.NO_WRAP);

有人可以向我解释我做错了什么吗?

谢谢

4

0 回答 0