2012-06-17 50 views
0

在我的應用程序中,我使用的是以base64Binary格式返回圖像的Web服務。 我正在使用kso​​ap2與網絡服務進行交互。Android:將Base64Binary轉換爲圖像

任何人都可以提供有關如何接收base64Binary,然後將其轉換爲圖像的任何幫助?

這是我使用的與web服務交互的代碼。

SoapObject request = new SoapObject(NAMESPACE, METHOD_GET_CONTROL); 
SoapSerializationEnvelope envelope = 
    new SoapSerializationEnvelope(SoapEnvelope.VER11); 
envelope.dotNet = true; 
envelope.setOutputSoapObject(request); 


HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); 

try { 
     androidHttpTransport.call(SOAP_ACTION_GET_CONTROL, envelope); 
     ..........=envelope.getResponse(); //To get the data. } 

如何以base64Binary格式接收數據然後將其轉換爲png圖像?

+2

請查看[鏈接] [1] [1]:http://stackoverflow.com/questions/4888746/android-get-image-from-base64binary-format 我認爲它可以幫助你。 謝謝。 –

+0

@MdAbdulGafur:是的,它工作。謝謝。 – Swayam

回答

0

至於建議由@MdAbdulGafur,下面的答案爲我工作:

decodedIcon[] = null; 
byte[] bb = (resposeString).getBytes("utf-8"); 
decodedIcon = Base64.decodeBase64(bb); 

Bitmap bitmap = BitmapFactory.decodeByteArray(decodedIcon, 0, decodedIcon.length); 

mImageView.setImageBitmap(bitmap); 

來源:This question