1

我正在尝试从安全网站获取 inputStream,将其转换为位图并显示。我现在设置代码的方式(日志显示字节数组的长度等)是因为我的错误是

01-25 10:29:44.857: D/skia(13452): --- SkImageDecoder::Factory 返回 null

但是,该字节数组长度检查会响应:

01-25 10:29:44.834:W/字节长度(13452):21844

我认为这一定意味着我的字节数组没有被正确下载,但我不知道如何检查/无论如何我将如何修复它。

我包含了我的 defaultHttpClient 代码,因为我想确保我处理安全性的方式不会以某种方式影响数据。

HttpPost post = new HttpPost("https://my.patlive.com//mailbox/messages/get.aspx?MsgID=" + messageId + "&format=bmp");

List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(3);

nameValuePairs.add(new BasicNameValuePair("username", username));
nameValuePairs.add(new BasicNameValuePair("password", password));

post.setEntity(new UrlEncodedFormEntity(nameValuePairs));

BitmapFactory.Options o = new BitmapFactory.Options();

o.inJustDecodeBounds = true;

InputStream is = httpclient.execute(post).getEntity().getContent();
byte[] bytes = readFully(is);

Log.w("bytes length", "" + bytes.length);

bmp = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);

在此先感谢,这让我困扰了几天。

4

0 回答 0