mercredi 24 décembre 2014

BitmapFactory returning null

I am trying to make an app where I need to store and retrieve a image in and from a SQLite Database. I am getting the program to store the image as a byte array using BLOB and I am also able to retrieve the byte array, but while decoding the array into a bitmap, BitmapFactory returns null. Please help. Here is the code I am using to decode the array.



Cursor c=db.rawQuery("SELECT * FROM student WHERE name='"+"1"+"'", null);
if(c.moveToFirst())
{
byte[] outImage=c.getBlob(1);
Log.d("The out image is", String.valueOf(outImage));
Bitmap bitmap = BitmapFactory.decodeByteArray(outImage , 0, outImage .length);
iv.setImageBitmap(bitmap);
}


The logcat reads something like this



12-24 23:39:49.777: E/output before conversion(22523): [B@13fd7069
12-24 23:39:49.778: D/Insert:(22523): Inserting ..
12-24 23:39:49.840: D/Success:(22523): Image Saved
12-24 23:39:51.579: D/The out image is(22523): [B@155f0aee
12-24 23:39:51.580: D/skia(22523): --- SkImageDecoder::Factory returned null

Aucun commentaire:

Enregistrer un commentaire