0
byte[] imageInByte;
ImageView iViewAddImage;

if (imageInByte.length>0) {
   Bitmap bitmap = BitmapFactory.decodeByteArray(imageInByte, 0, imageInByte.length);
   iViewAddImage.setImageBitmap(bitmap);
 }

我得到了Bitmap价值nullimageInByte.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;
  }
4

1 回答 1

0

这可能会帮助你

byte imageinbyte[];
bitmap bmp;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
                bmp.compress(Bitmap.CompressFormat.JPEG, 100, bos);
                imageInByte = bos.toByteArray();

可以直接设置图片查看背景

ImageView.setImageBitmap(bmp);|
于 2013-10-30T11:45:10.240 回答