簡體   English   中英

如何在android的Imageview中設置BLOB圖像?

[英]how to set BLOB image in Imageview in android?

您好,我將圖像作為 blob 存儲在數據庫中,並以字符串形式從數據庫中檢索圖像。 現在我想在 imageview 中設置這個圖像。 我試圖將它轉換為位圖,但沒有顯示出來。我已經完成了這樣的代碼。請幫忙提前謝謝

在日志中,我正在播種這種格式的照片:[ B@4052b078 ]

byte[] imageAsBytes = Base64.decode(sp_photo.getBytes(), 0);
alert_photo.setImageBitmap(BitmapFactory.decodeByteArray(imageAsBytes, 0, Bytes.length));

這里 sp_photo 是我的照片字符串路徑。 alert_photo 是圖像視圖。 請告訴我

試試這個,它可能會起作用:

BitmapFactory.Options options = new BitmapFactory.Options();
options.inDither = false;
options.inPurgeable = true;
options.inInputShareable = true;
options.inTempStorage = new byte[1024 *32];

Bitmap bm = BitmapFactory.decodeByteArray(imageAsBytes, 0, imageAsBytes.length, options);
alert_photo.setImageBitmap(bm);

暫無
暫無

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

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