2012-11-10 80 views
1

你好,我將數據庫中的圖像存儲爲blob,並從字符串中檢索數據庫中的圖像。 現在我想在imageview中設置此圖像。我試圖把它轉換成位圖,但不顯示它。我已經做了我的代碼this.plz幫助的感謝狀提前如何在Android的Imageview中設置BLOB圖像?

日誌

我正在播種照片的該格式:[B @ 4052b078]

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

這裏sp_photo是我的照片的字符串路徑。 和alert_photo是imageview。 PLZ告訴我

回答

2

試試這個,它可能工作:

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); 
相關問題