【问题标题】:Display Image with Universal ImageLoader with Bitmap使用带位图的通用 ImageLoader 显示图像
【发布时间】:2014-11-26 01:46:48
【问题描述】:

如果我有位图并且不想使用通用 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)

【问题讨论】:

  • 如果你有 Bitmap 和 ImageView,你可以简单地使用 ImageView.setImageBitmap(img) 而无需任何加载器 ...

标签: java android bitmap universal-image-loader


【解决方案1】:

首先, 您必须保存位图,然后您可以通过该路径以使用 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);

【讨论】:

  • 真是浪费时间......如果他有imageview和bitmap,那么根本不需要加载器......
  • 请将压缩行 .PNG 更改为 .JPEG.. 然后上面的代码就可以正常工作了..
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-10-26
相关资源
最近更新 更多