當我嘗試創建帶解碼字符串的位圖時,我得到一個從.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