在控制台应用程序中创建图像或位图 - 似乎无法找到System.Drawing?

How*_*ter 7 c# bitmap console-application

我正在尝试从相机比特流创建一个图像或位图,我将(希望)通过websocket传递给浏览器.我正在构建的应用程序是一个控制台应用程序,因为我认为这个应用程序不需要有GUI.现在我在创建/访问Image和Bitmap类时遇到了麻烦 - System.Drawing似乎不存在,我不知道为什么.当我尝试时,using System.Drawing我得到错误The type or namespace name 'Drawing' does not exist in the namespace 'System' (are you missing an assembly reference?)什么是在控制台应用程序中创建位图的最佳方法,有没有理由我似乎无法加载System.Drawing?

码:

private void Kinect_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
{
    using (ColorImageFrame frame = e.OpenColorImageFrame())
    {
        if (frame != null)
        {
            byte[] pixelData = new byte[frame.PixelDataLength];
            frame.CopyPixelDataTo(pixelData);
            //how do we create a bitmap here and pass it off to chrome?

        }
    }
}
Run Code Online (Sandbox Code Playgroud)

Moi*_*oiz 27

您必须在项目中添加对system.Drawing.Dll的引用.

右键单击Project,添加引用并查找System.Drawing.DLL并添加引用.

编辑:您将在Assemblies-> Framework-> System.Drawing下找到它

  • 唉,耻辱,它燃烧.谢谢. (4认同)

Igo*_*gor 5

将 System.Drawing.dll 作为参考程序集添加到您的项目中。