How to convert image to byte array

前端 未结 12 1408
悲哀的现实
悲哀的现实 2020-11-22 09:52

Can anybody suggest how I can convert an image to a byte array and vice versa?

I\'m developing a WPF application and using a stream reader.

12条回答
  •  北海茫月
    2020-11-22 10:39

    For Converting an Image object to byte[] you can do as follows:

    public static byte[] converterDemo(Image x)
    {
        ImageConverter _imageConverter = new ImageConverter();
        byte[] xByte = (byte[])_imageConverter.ConvertTo(x, typeof(byte[]));
        return xByte;
    }
    

提交回复
热议问题