【发布时间】:2016-11-22 02:49:09
【问题描述】:
我正在尝试从以下网址加载图像: https://fangkarte.de:8080/fangfisch/file/files/592036af55dfffca0155e01fe10002f7
在 Chrome/IE 中,图像将毫无问题地显示。当我尝试在 Android 上加载图像时,我无法将图像存储为 PNG 文件。每次将图像保存为文本文件,其中包含图像为 base64 字符串。
我也尝试了以下代码,但 decodedByte 为空:
byte[] decodedString = Base64.decode(encodedImage, Base64.DEFAULT);
Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
有没有人知道如何将来自 url 的图像显示为位图,或者我更喜欢将图像作为 png 存储在设备上?
【问题讨论】:
-
用它来加载 img square.github.io/picasso
-
感谢您的建议,但不幸的是,毕加索在这种特殊情况下不起作用。我试过了
-
decodedString 的大小是多少?
-
Everytime the image will be saved as a textfile你没有展示你是如何做到的。而且你没有告诉这个文本文件包含什么。但是 byte[] decodedString 应该包含 png。因此,将 byte[] decodedString 保存到文件以生成 .png 文件。
标签: android image bitmap base64 png