I try to send an image to my sqlite database, and then to get back from the database to the appearance of an imageView. But during the execution of the program, i take no image to the image view and i get an error from Xamarin app output console . Where is the wrong in my code?
This is code, that i save image in database :
Bitmap bitmap = BitmapFactory.DecodeStream(stream);
MemoryStream memStream = new MemoryStream();
bitmap.Compress(Bitmap.CompressFormat.Png, 100, memStream);
byte[] picData = memStream.ToArray();
_imgArt = Convert.ToBase64String(picData);
}
And this code, retrieve image to imageview :
Bundle extras = Intent.Extras;
if (extras != null) {
string image = sqldb_cursor.GetString (sqldb_cursor.GetColumnIndex ("Art"));
byte[] photo = Convert.FromBase64String (image);
if (mArt != null)
{
var imageBitmap = BitmapFactory.DecodeByteArray(photo, 0, photo.Length);
RunOnUiThread(() => mArt.SetImageBitmap(imageBitmap));
}
And the error from Xamarin :
BitmapFactory﹕ Unable to decode stream: java.io.FileNotFoundException:
Aucun commentaire:
Enregistrer un commentaire