gpt4 book ai didi

java - 如何解码以 Base64 编码的 png 图像并在 ImageView 上查看它?

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:58:23 28 4
gpt4 key购买 nike

我的 android 设备向服务器请求一个 png 图像。服务器以 Base64 编码图像并将其发送到我的设备。之后,我将 Base64 字符串解码为字节数组并使用 BitmapFactory.decodeByteArray() 制作它的位图图像。当我将图像添加到 ImageView 中时,我看不到图像。

代码见下:

JSONObject params = resultObject.getJSONObject("params");
byte[] decodedImageInBytes = Base64.decode(params.getString("image_one"), Base64.DEFAULT);

Bitmap myImage = BitmapFactory.decodeByteArray(decodedImageInBytes, 0, decodedImageInBytes.length);
ImageView imageViewOne = (ImageView) findViewById(R.id.imageViewOne);
imageViewOne.setImageBitmap(myImage);

编辑:

看来我的代码没问题,我的服务器有点问题。谢谢大家!

最佳答案

我已经为你解码了你的字符串。它不是位图数据。

Unknown error type: [2] include(/home/hospitalit/domains/hospitalitymanager.nl/public_html/demo/application//controllers/global/statistic_images/reservation_guest_rank) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory<br />
on line 45 in file /home/hospitalit/domains/hospitalitymanager.nl/public_html/demo/application/controllers/api/statistics/index.phpUnknown error type: [2] include() [<a href='function.include'>function.include</a>]: Failed opening '/home/hospitalit/domains/hospitalitymanager.nl/public_html/demo/application//controllers/global/statistic_images/reservation_guest_rank' for inclusion (include_path='.:/usr/local/lib/php')<br />
on line 45 in file /home/hospitalit/domains/hospitalitymanager.nl/public_html/demo/application/controllers/api/statistics/index.php

关于java - 如何解码以 Base64 编码的 png 图像并在 ImageView 上查看它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10048747/

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