我必须从服务器检索到Android手机的所有尺寸的图像参考编号,让我试着用下面这样的编码,并成功拿到了基地64串和base64string它工作于小尺寸的图像检索到的图像等效的,但是当我去对于大尺寸图片仍然黑屏无法通过这种方法来获得屏幕的大尺寸图像。
提前致谢。
如何检索
通过肥皂对象大尺寸的base64串从服务器
package com.imageload;
import java.io.IOException;
import java.util.StringTokenizer;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParserException;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Typeface;
import android.os.Bundle;
import android.util.Base64;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
public class ImageloadActivity extends Activity {
/** Called when the activity is first created. */
private Button submit,clr,ext;
private ImageView imageView;
private TextView institute,orderno,name,mobno,handeled,regdat,delvdat,pname,pamt,dirby,regby,delby;
String val11,val12,val13,val14;
String str = null,str2 = null;
String error="0",IiD;
/* private static final String SOAP_ACTION = "http://tempuri.org/sta1";
private static final String METHOD_NAME = "sta1";
private static final String NAMESPACE = "http://tempuri.org/";
private static final String URL = "http://cyberstudents.in/newand//service.asmx";*/
private static final String SOAP_ACTION = "http://tempuri.org/IMAGE";
private static final String METHOD_NAME = "IMAGE";
private static final String NAMESPACE = "http://tempuri.org/";
//private static final String URL = "http://cyberstudents.in/crdroid//service.asmx";
private static final String URL = "http:///localdb/Service.asmx";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
this.orderno=(TextView)this.findViewById(R.id.ordernoeditText);
this.pname=(TextView)this.findViewById(R.id.insTextView);
this.submit=(Button)this.findViewById(R.id.getbutton);
this.clr=(Button)this.findViewById(R.id.clearbutton);
this.ext=(Button)this.findViewById(R.id.Exitbutton);
this.imageView =(ImageView) findViewById(R.id.imageView1);
orderno.setText("CB2-1112-CEA0883");
this.submit.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
IiD=orderno.getText().toString();
if(error.equals("0"))
{
SoapObject request = new SoapObject(NAMESPACE,METHOD_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
request.addProperty("ID",IiD);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try
{
try
{
androidHttpTransport.call(SOAP_ACTION, envelope);
}
catch (XmlPullParserException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
SoapPrimitive result = (SoapPrimitive)envelope.getResponse();
//to get the data should be a base
String resultData = result.toString();
//pname.setText(resultData);
byte[] decodedString = Base64.decode(resultData, Base64.DEFAULT);
Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
imageView.setImageBitmap(decodedByte);
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
});
this.clr.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
pname.setText("");
}
});
this.ext.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
System.exit(0);
}
});
}
}
它返回null soapprimitive(结果),当它返回的图像尺寸大于150KB或2500 * 3000渔政船
[WebMethod]
public string IMAGE(string ID)
{
SqlConnection conn = new SqlConnection("Data Source=;Initial Catalog=;Persist Security Info=True;User ID=sa;");
conn.Open();
SqlDataAdapter sdImageSource = new SqlDataAdapter();
sdImageSource.SelectCommand = new SqlCommand("select ImageData from ImagesStore where ImageId=('" + ID + "')", conn);
DataSet dsImage = new DataSet();
sdImageSource.Fill(dsImage);
byte[] blob = (byte[])dsImage.Tables[0].Rows[0][0];
int k = blob.Length;
string c = Convert.ToBase64String(blob);
return c;
}