Display Image with Universal ImageLoader with Bitmap

拟墨画扇 提交于 2019-12-11 10:18:55

问题


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.

 Bitmap img = getDefaultBitmap();
 ImageLoader.getInstance().displayImage(img); // I need something like this (for example with parameters to display image like width and height)

回答1:


Firstly, you have to save bitmap and then u can pass that path to show that bitmap into imageview using imageloader.

//-- 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);


来源:https://stackoverflow.com/questions/26137647/display-image-with-universal-imageloader-with-bitmap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!