-
米脂
将图像转换为字节数组的示例代码public byte[] ImageToByteArray(System.Drawing.Image imageIn){
using (var ms = new MemoryStream())
{
imageIn.Save(ms,imageIn.RawFormat);
return ms.ToArray();
}}字节数组和字节数组到图像转换器类的C#图像
-
繁星coding
用于将Image对象转换为byte[]你可以这样做:public static byte[] converterDemo(Image x){
ImageConverter _imageConverter = new ImageConverter();
byte[] xByte = (byte[])_imageConverter.ConvertTo(x, typeof(byte[]));
return xByte;}
-
HUWWW
试试这个:public byte[] imageToByteArray(System.Drawing.Image imageIn){
MemoryStream ms = new MemoryStream();
imageIn.Save(ms,System.Drawing.Imaging.ImageFormat.Gif);
return ms.ToArray();}public Image byteArrayToImage(byte[] byteArrayIn){
MemoryStream ms = new MemoryStream(byteArrayIn);
Image returnImage = Image.FromStream(ms);
return returnImage;}