【问题标题】:Convert a byte [] to Image<Bgr, Byte>将字节 [] 转换为 Image<Bgr, Byte>
【发布时间】:2017-12-12 01:20:00
【问题描述】:

我正在尝试将字节数组转换为图像。网上有很多参考资料可以这样做,例如 this SO postthis emgu forumemgu official docs

但是,当我根据 SO 帖子和 Emgu 文档实施解决方案时出现错误

无法从 System.Drawing.Bitmap 转换为 byte[*,*,*,*]

public Image<Bgr, Byte> CreateImageFromBytesArray(byte[] bytes)
{
    using (var ms = new MemoryStream(bytes))
    {
        Bitmap bmp = new Bitmap(ms);
        Image<Bgr, Byte> img = new Image<Bgr, Byte>(bmp); //EXCEPTION HERE
        return img;
    }
}

关于如何进行这项工作的任何建议?

【问题讨论】:

  • 哪一行出现异常?
  • 见上面的代码

标签: c# image bitmap emgucv


【解决方案1】:
public Image<Bgr, Byte> CreateImageFromBytesArray(byte[] bytes)
{
    Image<Bgr, Byte> image = new Image<Bgr, Byte>(width, height);
    image.Bytes = bytes
    return image;
}

【讨论】:

    猜你喜欢
    • 2012-08-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-10
    • 1970-01-01
    相关资源
    最近更新 更多