【发布时间】:2013-10-30 10:39:33
【问题描述】:
byte[] imageInByte;
ImageView iViewAddImage;
if (imageInByte.length>0) {
Bitmap bitmap = BitmapFactory.decodeByteArray(imageInByte, 0, imageInByte.length);
iViewAddImage.setImageBitmap(bitmap);
}
我得到了Bitmap 值null 和imageInByte.length=20621。
做错了什么。建议我?
编辑 1:
public void insertImage(byte[] imageInByte2)
{
if(sqliteDb != null)
{
try {
sqliteDb.insert("database",null,getDataValues(imageInByte2));
} catch(Exception e) {
e.printStackTrace();
}
}
}
private ContentValues getDataValues(byte[] imageInByte2){
ContentValues contentValues = new ContentValues();
try {
contentValues.put("image",imageInByte2);
}
catch (Exception e) {
e.printStackTrace();
}
return contentValues;
}
【问题讨论】:
-
您在字节数组中添加了图像字节的位置?试试
byte[] imageInByte=new byte[1024]; -
你需要将图片转换成字节数组,然后才添加解码。
-
我已将字节数组添加到数据库中并从那里重新获取... @GrIsHu
-
你可以在存储到数据库之前发布代码如何生成字节数组
标签: android bitmap bytearray bitmapfactory