对于较大的图像Android的图片消气 [英] Android Image Getter for Larger Images
问题描述
我都用标准的网络相关的$ C $下获取图像约 45KB到75KB
但都没有这些方法做工精细的文件约 3-5KB
图像大小。我怎样才能实现下载的 45图片 - 75KB
在Android的展示他们的ImageView的,因为我已经用我的网络运营的事情是
I have used all the Standard Network related code for Getting Images of about 45KB to 75KB
but all are failing these methods work fine for Files of about 3-5KB
size of Images. How can I achieve Downloading Image of 45 - 75KB
for displaying them on an ImageView in Android for my Network Operations the Things I have used are
final URL url = new URL(urlString);
final URLConnection conn = url.openConnection();
HttpURLConnection httpConn = (HttpURLConnection) conn;
httpConn.setAllowUserInteraction(true);
httpConn.setInstanceFollowRedirects(true);
httpConn.setRequestMethod("GET");
httpConn.connect();
和我已经用了第二个选项是::
and the Second option that I have had used is::
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet getRequest = new HttpGet(urlString);
HttpResponse response = httpClient.execute(getRequest);
这是为什么code功能的小尺寸图像,而不是为大尺寸图像。 ?
why is this code functional for Smaller Sized Images and not for Larger Size Images. ?
推荐答案
这将是很好看你用的响应转化为位图解码什么样的code。无论如何,尝试使用这样的的BufferedInputStream:
It would be nice to see what kind of code you use for decoding the response into a bitmap. Anyway, try using a BufferedInputStream like this:
public Bitmap getRemoteImage(final URL aURL) {
try {
final URLConnection conn = aURL.openConnection();
conn.connect();
final BufferedInputStream bis = new BufferedInputStream(conn.getInputStream());
final Bitmap bm = BitmapFactory.decodeStream(bis);
return bm;
} catch (IOException e) {
Log.d("DEBUGTAG", "Oh noooz an error...");
}
return null;
}
这篇关于对于较大的图像Android的图片消气的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!