[英]Display Image with Universal ImageLoader with Bitmap
I wonder how to display image if I have a Bitmap and don't want to give as a parameter URL to image using Universal ImageLoader library. 我想知道如果我有位图并且不想使用Universal ImageLoader库作为图像的参数URL来显示图像。
Bitmap img = getDefaultBitmap();
ImageLoader.getInstance().displayImage(img); // I need something like this (for example with parameters to display image like width and height)
Firstly, you have to save bitmap and then u can pass that path to show that bitmap into imageview using imageloader. 首先,您必须保存位图,然后您可以通过该路径使用imageloader将位图显示到imageview中。
//-- Saving file
String filename = "pippo.jpg";
File sd = Environment.getExternalStorageDirectory();
File dest = new File(sd, filename);
Bitmap bitmap = (Bitmap)data.getExtras().get("data");
try {
FileOutputStream out = new FileOutputStream(dest);
bitmap.compress(Bitmap.CompressFormat.PNG, 90, out);
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
}
//-- show bitmap to imageview
imageLoader.displayImage(dest.getAbsolutePath(), imageView);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.