简体   繁体   English

如何在android的Imageview中设置BLOB图像?

[英]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.您好,我将图像作为 blob 存储在数据库中,并以字符串形式从数据库中检索图像。 now i want to set this image in imageview.现在我想在 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 ]在日志中,我正在播种这种格式的照片:[ 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.这里 sp_photo 是我的照片字符串路径。 and alert_photo is the imageview. alert_photo 是图像视图。 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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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