问题
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