Convert image to binary?

前端 未结 8 2206
南旧
南旧 2021-02-08 04:07

I have an image (in .png format), and I want this picture to convert to binary.

How can this be done using C#?

8条回答
  •  被撕碎了的回忆
    2021-02-08 04:35

    public static byte[] ImageToBinary(string imagePath)
        {
            FileStream fS = new FileStream(imagePath, FileMode.Open, FileAccess.Read);
            byte[] b = new byte[fS.Length];
            fS.Read(b, 0, (int)fS.Length);
            fS.Close();
            return b;
        }
    

    just use above code i think your problem will be solved

提交回复
热议问题