How to convert bitmap to byte array in Mono For Android

前端 未结 2 1961
挽巷
挽巷 2021-01-12 12:41

I am using Mono for Android, I would like to save a bitmap to a byte array  So I can save it to a database.

Searching in here I found the following piece of code:

2条回答
  •  被撕碎了的回忆
    2021-01-12 12:46

    You need to use MemoryStream in MonoDroid instead. Try this:

    MemoryStream stream = new MemoryStream();
    bitmap.Compress(Bitmap.CompressFormat.Png, 0, stream);
    byte[] bitmapData = stream.ToArray();
    

提交回复
热议问题