gpt4 book ai didi

java - byte[] 不会解析为图像

转载 作者:行者123 更新时间:2023-12-02 06:41:03 25 4
gpt4 key购买 nike

我的 ListView 有一个自定义适配器,它填充了我在其中放入数据的自定义 rowItem 类的 ArrayList。

rowItem.getImage() 将返回此字节数组:我已将长字符串放在 byte[] 变量中,并使用 getBytes()

R0lGODlhZAAvAPcAAAAAAAAAMwAAZgAAmQAAzAAA/wArAAArMwArZgArmQArzAAr/wBVAABVMwBVZgBVmQBVzABV/wCAAACAMwCAZgCAmQCAzACA/wCqAACqMwCqZgCqmQCqzACq/wDVAADVMwDVZgDVmQDVzADV/wD/AAD/MwD/ZgD/mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMrADMrMzMrZjMrmTMrzDMr/zNVADNVMzNVZjNVmTNVzDNV/zOAADOAMzOAZjOAmTOAzDOA/zOqADOqMzOqZjOqmTOqzDOq/zPVADPVMzPVZjPVmTPVzDPV/zP/ADP/MzP/ZjP/mTP/zDP//2YAAGYAM2YAZmYAmWYAzGYA/2YrAGYrM2YrZmYrmWYrzGYr/2ZVAGZVM2ZVZmZVmWZVzGZV/2aAAGaAM2aAZmaAmWaAzGaA/2aqAGaqM2aqZmaqmWaqzGaq/2bVAGbVM2bVZmbVmWbVzGbV/2b/AGb/M2b/Zmb/mWb/zGb//5kAAJkAM5kAZpkAmZkAzJkA/5krAJkrM5krZpkrmZkrzJkr/5lVAJlVM5lVZplVmZlVzJlV/5mAAJmAM5mAZpmAmZmAzJmA/5mqAJmqM5mqZpmqmZmqzJmq/5nVAJnVM5nVZpnVmZnVzJnV/5n/AJn/M5n/Zpn/mZn/zJn//8wAAMwAM8wAZswAmcwAzMwA/8wrAMwrM8wrZswrmcwrzMwr/8xVAMxVM8xVZsxVmcxVzMxV/8yAAMyAM8yAZsyAmcyAzMyA/8yqAMyqM8yqZsyqmcyqzMyq/8zVAMzVM8zVZszVmczVzMzV/8z/AMz/M8z/Zsz/mcz/zMz///8AAP8AM/8AZv8Amf8AzP8A//8r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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==

现在我有这个代码:

    byte[] imageData = rowItem.getImage();
Drawable logoDrawable = null;
if (imageData != null) {
Bitmap logoBitmap = BitmapFactory.decodeByteArray(imageData, 0,
imageData.length);
logoDrawable = new BitmapDrawable(context.getResources(), logoBitmap);
}
holder.imageView.setImageDrawable(logoDrawable);

但它不会显示图像,如果我从可绘制 map 中设置图像,它将显示出来,以便重新调整 ImageView 。

最佳答案

您显示的不是字节数组 - 它是文本,看起来非常像 base64 数据。

你应该尝试decoding it from base64首先到“原始”字节:

byte[] imageData = Base64.decode(rowItem.getImage(), Base64.DEFAULT);

...或者修复您获取 rowItem 的位置,以便为您执行 Base64 解码。

关于java - byte[] 不会解析为图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19133927/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com