0
byte[] imageInByte;
ImageView iViewAddImage;
if (imageInByte.length>0) {
Bitmap bitmap = BitmapFactory.decodeByteArray(imageInByte, 0, imageInByte.length);
iViewAddImage.setImageBitmap(bitmap);
}
我得到Bitmap
值null
和imageInByte.length=20621
。解码时给出null的位图?
什么在做错。让我难过?
编辑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
看到这个。 http://stackoverflow.com/questions/6520745/why-does-bitmapfactory-decodebytearray-return-null – blitzen12
你需要将图像转换为字节数组,然后只添加它进行解码。 – GrIsHu