当我尝试创建带解码字符串的位图时,我得到一个从.net Web服务的base64Binary中编码的图像,我得到null。任何想法为什么? thx为您的帮助! :dAndroid:BitmapFactory.decodeByteArray返回null解码base64图像
我敢肯定响应字符串不为空,我测试了它和它的长度为28000。我也查了一个在线解码器的内容和它返回我需要的图像。
我使用的是Android原生的Base64图书馆使用bitmapfactory
我用Ksoap2来获得图像的base64字符串
这是Android 2.2的谷歌API
之前对其进行解码代码如下:
String serverResponse = "" + result.get(0);
byte[] decodedString = Base64.decode(serverResponse, Base64.DEFAULT);
imgMap = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
ImgMap是位图,它总是变为空,我做错了什么?
我得到的说,一个日志条目:
TAG: SKIA
TEXT: ---SkImageDecoder:: Factory returned null
这是decodedString的样子:
06-13 03:09:54.957: D/CODED(491): SIZE: 22486
06-13 03:09:55.008: D/CODED(491): Content: first 200 positions of the array: 737342012400068796785786984327110111410997110121068656783328411111110810710511632737305048495058485358505132494858515158525200000000000000000000000000000000000000000000000000000000000000000250-20401000000001301000-22900113010003930021301000100031301000400061301000000071
“decodedString”是否包含图像? – Christine
它应该包含代表图像的base64解码字节,它不是空的 – Matthew
“应该”与“is”不一样。您可以在调试应用程序时检查它,也可以将字符串写入日志输出。 – Christine