簡體   English   中英

使用具有位圖的Universal ImageLoader顯示圖像

[英]Display Image with Universal ImageLoader with Bitmap

我想知道如果我有位圖並且不想使用Universal 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)

首先,您必須保存位圖,然后您可以通過該路徑使用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);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM