Hello,
Welcome to our Microsoft Q&A platform!
I think you should use like this:
byte [] imageArray // is your data
MemoryStream mStream = new MemorySteram ();
mStream.write(imageArray,0,imageArray.Length);
Image img = Image.FromStream(mStream);
img.save(filelocation);
Bitmap bitmapimg = BitmapFactory.BitmapFactory.DecodeStream(mStream);
// if you want to use Bitmap
For how to use bitmap, you can refer to the following code:
var bitmap = BitmapFactory.BitmapFactory.DecodeStream(stream);
var path = Path.Combine(GetExternalFilesDir(Environment.DirectoryDocuments).AbsolutePath, "sameImagePath.jpg");
if (!File.Exists(path))
{
using (var filestream = new FileStream(path, FileMode.Create))
{
if (bitmap.Compress(Bitmap.CompressFormat.Jpeg, 50, filestream))
{
filestream.Flush();
}
else {} // handle failure case...
}
}
bitmap.Recycle();
bitmap.Dispose();
Refer:https://stackoverflow.com/questions/43899497/create-image-file-from-byte-array-in-documents-xamarin-android
And there are some similar threads about this, you can check:
https://stackoverflow.com/questions/49721271/byte-array-to-image-using-c-sharp-in-xamarin
https://stackoverflow.com/questions/9173904/byte-array-to-image-conversion
Best Regards,
Jessie Zhang
---
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.