byte []的图像机器人 [英] byte[] to image android
问题描述
我的问题如下: 我已经保存了几张照片到SQLite数据库,使用blob的格式,这似乎工作确定。现在我想我的照片了数据库,并把再放回图像...来把问题复杂化,它们的格式是可变的(PNG,JPG,也许别的东西,林不知道) 有没有在机器人这样的一种方式?
My issue is as follows : I have stored a few pictures into the sqlite database, using the blob format, which seems to work ok. now i want to get my pictures out of the DB and put then back into images... to complicate the matter, their format is variable (png, jpg, maybe something else, im not sure) Is there a way of doing so in android?
谢谢
推荐答案
使用<一个href="http://developer.android.com/intl/it/reference/android/graphics/BitmapFactory.html#de$c$cByteArray">BitmapFactory.de$c$cByteArray()方法:
byte[] blob=c.getBlob("yourcolumnname");
Bitmap bmp=BitmapFactory.decodeByteArray(blob,0,blob.length);
ImageView image=new ImageView(this);
image.setImageBitmap(bmp);
看<一href="http://groups.google.com/group/android-developers/browse_thread/thread/0eca3333d32a314c">this跟帖了。
这篇关于byte []的图像机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!