简体   繁体   中英

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.

 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM