我怎样才能获取从URL一个大的图像? [英] How can I fetch a large image from a url?
本文介绍了我怎样才能获取从URL一个大的图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用code以下,从一个网址抓取图像,但它不工作的高画质图像。
我缺少的东西时,取该类型的形象?
imgView =(ImageView的)findViewById(R.id.ImageView01);
imgView.setImageBitmap(loadBitmap(http://www.360technosoft.com/mx4.jpg));
//imgView.setImageBitmap(loadBitmap("http://sugardaddydiaries.com/wp-content/uploads/2010/12/how_do_i_get_sugar_daddy.jpg"));
//setImageDrawable("http://sugardaddydiaries.com/wp-content/uploads/2010/12/holding-money-copy.jpg");
//绘制对象绘制= LoadImageFromWebOperations(http://www.androidpeople.com/wp-content/uploads/2010/03/android.png);
//imgView.setImageDrawable(drawable);
/* 尝试 {
ImageView的I =(ImageView的)findViewById(R.id.ImageView01);
点阵位图= BitmapFactory.de codeStream((InputStream的)新的URL(http://sugardaddydiaries.com/wp-content/uploads/2010/12/holding-money-copy.jpg).getContent()) ;
i.setImageBitmap(位);
}赶上(MalformedURLException异常E){
的System.out.println(你好);
}赶上(IOException异常E){
的System.out.println(你好);
} * /
}
受保护的可绘制ImageOperations(上下文的背景下,串串,
字符串字符串2){
// TODO自动生成方法存根
尝试 {
InputStream的是=(的InputStream)this.fetch(串);
绘制对象D = Drawable.createFromStream(是,SRC);
返回D组;
}赶上(MalformedURLException异常E){
e.printStackTrace();
返回null;
}赶上(IOException异常E){
e.printStackTrace();
返回null;
}
}
解决方案
看这很好的例子加载图像的服务器。 <一href="http://blog.sptechnolab.com/2011/03/04/android/android-load-image-from-url/.">blog.sptechnolab.com/2011/03/04/android/android-load-image-from-url/.
I used the code below to fetch the image from a url but it doesn't working for large images.
Am I missing something when fetching that type of image?
imgView = (ImageView)findViewById(R.id.ImageView01);
imgView.setImageBitmap(loadBitmap("http://www.360technosoft.com/mx4.jpg"));
//imgView.setImageBitmap(loadBitmap("http://sugardaddydiaries.com/wp-content/uploads/2010/12/how_do_i_get_sugar_daddy.jpg"));
//setImageDrawable("http://sugardaddydiaries.com/wp-content/uploads/2010/12/holding-money-copy.jpg");
//Drawable drawable = LoadImageFromWebOperations("http://www.androidpeople.com/wp-content/uploads/2010/03/android.png");
//imgView.setImageDrawable(drawable);
/* try {
ImageView i = (ImageView)findViewById(R.id.ImageView01);
Bitmap bitmap = BitmapFactory.decodeStream((InputStream)new URL("http://sugardaddydiaries.com/wp-content/uploads/2010/12/holding-money-copy.jpg").getContent());
i.setImageBitmap(bitmap);
} catch (MalformedURLException e) {
System.out.println("hello");
} catch (IOException e) {
System.out.println("hello");
}*/
}
protected Drawable ImageOperations(Context context, String string,
String string2) {
// TODO Auto-generated method stub
try {
InputStream is = (InputStream) this.fetch(string);
Drawable d = Drawable.createFromStream(is, "src");
return d;
} catch (MalformedURLException e) {
e.printStackTrace();
return null;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
解决方案
see this good example that loads image from server. blog.sptechnolab.com/2011/03/04/android/android-load-image-from-url/.
这篇关于我怎样才能获取从URL一个大的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文