Skip to content Skip to sidebar Skip to footer

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(); ImageLoa

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

Post a Comment for "Display Image With Universal Imageloader With Bitmap"