简体   繁体   中英

how to set BLOB image in Imageview in android?

Hello I am store the image in database as blob and retrive the image from database in string. now i want to set this image in imageview. i tried to convert it in bitmap but not displayed it.i have done my code like this.plz help thanks in advance

in log i am sowing that format of photo:[ B@4052b078 ]

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

here sp_photo is my string path of photo. and alert_photo is the imageview. plz tell me

Try this, it might work:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM