【问题标题】:Cant convert image to bytearray无法将图像转换为字节数组
【发布时间】:2019-05-18 06:55:44
【问题描述】:

我正在尝试将图片框转换为字节数组

MemoryStream s = new MemoryStream();
picProfilePicture.Image.Save(s, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] pic = s.ToArray();

但是当我使用这种方法时,我在 GDI+ 中遇到了一般错误。我该如何解决?

【问题讨论】:

标签: c#


【解决方案1】:
    FileStream fs = new FileStream(selectedFile, FileMode.Open, FileAccess.Read);
    byte[] bimage = new byte[fs.Length];
    fs.Read(bimage, 0, Convert.ToInt32(fs.Length));

【讨论】:

    猜你喜欢
    • 2017-08-25
    • 2015-08-18
    • 1970-01-01
    • 2015-08-16
    • 2013-05-19
    • 2012-02-09
    • 2014-12-12
    相关资源
    最近更新 更多