我的问题如下:我已经使用blob格式将一些图片存储到sqlite数据库中,这似乎工作得很好。现在我想把我的图片从数据库中提取出来,然后放回图片中。让事情更复杂的是,他们的格式是可变的(png,jpg,也许是其他的,我不确定)在android中有办法做到这一点吗?
谢谢
发布于 2010-04-26 23:47:03
使用BitmapFactory.decodeByteArray()方法:
byte[] blob=c.getBlob("yourcolumnname");
Bitmap bmp=BitmapFactory.decodeByteArray(blob,0,blob.length);
ImageView image=new ImageView(this);
image.setImageBitmap(bmp);
也可以看看this线程。
发布于 2010-04-26 23:41:02
发布于 2017-03-23 02:38:20
我更喜欢将字节数组直接转换为Drawable。它是Android中使用的最好的格式。位图在过去产生了泄漏。
Drawable d = Drawable.createFromStream(new ByteArrayInputStream(ARRAY_BYTES), null);
https://stackoverflow.com/questions/2714700
复制相似问题