获取blob数据并使用imageView作为其容器

时间:2011-07-07 10:26:26

标签: android blob

我有一个sqlite数据库,它有一个blob列和blob数据。我尝试过以下但没有显示任何内容。请指教:

public Cursor getHiddenImages()
    {
        dbConnection connection=new dbConnection(getApplicationContext());
        SQLiteDatabase db=connection.getReadableDatabase();
        Cursor cursor=db.query(dbConnection.TABLE_IMAGES,null, null, null, null, null, null);
        return cursor;
    }
        cursor=getHiddenImages();
        cursor.moveToFirst();
        byte[]mybyteArray=cursor.getBlob(cursor.getColumnIndex(dbConnection.IMAGE_DATA));
        Bitmap theImage=BitmapFactory.decodeByteArray(mybyteArray, 0, mybyteArray.length);
        imageview.setImageBitmap(theImage);

1 个答案:

答案 0 :(得分:0)

试试此代码并查看以下链接

    Buffer = Cursor1.GetBlob("Image")
    Dim Canvas1 As Canvas
    Canvas1.Initialize(ImageView1)
    Dim IN As InputStream
    IN.InitializeFromBytesArray(Buffer,0,Buffer.Length)
    IN.Close
    Msgbox(buffer.Length,"Image lenght")
    Msgbox(In.BytesAvailable,"available")
    Canvas1.Bitmap.Initialize2(IN)
    ImageView1.Bitmap = Canvas1.Bitmap

查看这些链接,你可以解决你的问题 Assignin blob to imageview
display image from blob
Blob to imageView