是否有可能使用BitmapFactory.de codeFILE的方法去codeA形象从HTTP位置? [英] Is it possible to use BitmapFactory.decodeFile method to decode a image from http location?
本文介绍了是否有可能使用BitmapFactory.de codeFILE的方法去codeA形象从HTTP位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道是否有可能使用BitmapFactory.de codeFILE的方法去codeA形象从HTTP位置?
I would like to know if it is possible to use BitmapFactory.decodeFile method to decode a image from http location?
有关,例如。
ImageView imageview = new ImageView(context);
Bitmap bmp = BitmapFactory.decodeFile("http://<my IP>/test/abc.jpg");
imageview.setImageBitmap(bmp);
不过,BMP总是返回null。
But bmp is always returning null.
有没有达到这种情况下任何其他方式,在那里我有一组图像在我的服务器电脑,我是通过XML加载图片到我的画廊的应用程序?
Is there any other way to achieve this scenario, where i have a set of images in my server PC, and i am loading the images to my gallery application via an xml?
谢谢,
森
推荐答案
@Amir和放大器; @Sankar:感谢您的宝贵建议
@Amir & @Sankar : Thanks for your valuable suggestions.
我通过以下操作code段解决了上述问题:
I solved the above problem by doing the following code snippet :
ImageView iv = new ImageView(context);
try{
String url1 = "http://<my IP>/test/abc.jpg";
URL ulrn = new URL(url1);
HttpURLConnection con = (HttpURLConnection)ulrn.openConnection();
InputStream is = con.getInputStream();
Bitmap bmp = BitmapFactory.decodeStream(is);
if (null != bmp)
iv.setImageBitmap(bmp);
else
System.out.println("The Bitmap is NULL");
} catch(Exception e) {
}
谢谢,
森
Thanks,
Sen
这篇关于是否有可能使用BitmapFactory.de codeFILE的方法去codeA形象从HTTP位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文