How to convert bitmap to byte array in Mono For Android

前端 未结 2 1962
挽巷
挽巷 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();
    
    0 讨论(0)
  • 2021-01-12 13:00

    import this package import java.io.ByteArrayOutputStream;

    0 讨论(0)
提交回复
热议问题