Convert a image to a monochrome byte array

后端 未结 2 1310
失恋的感觉
失恋的感觉 2020-12-12 04:42

I am writing a library to interface C# with the EPL2 printer language. One feature I would like to try to implement is printing images, the specification doc says

2条回答
  •  遥遥无期
    2020-12-12 05:06

    If you just need to convert your bitmap into a byte array, try using a MemoryStream:

    Check out this link: C# Image to Byte Array and Byte Array to Image Converter Class

    public byte[] imageToByteArray(System.Drawing.Image imageIn)
    {
     MemoryStream ms = new MemoryStream();
     imageIn.Save(ms,System.Drawing.Imaging.ImageFormat.Gif);
     return  ms.ToArray();
    }
    

提交回复
热议问题