uint width = 640;
uint height = 640;
byte* pixels=0;
receiver.CreateReceiver(recname, ref width, ref height, true);
receiver.ReceiveImage(recname, ref width, ref height, pixels, 0, false, 1);

For C# you need an interface with C++. You might find some details from -



Translation -

  1. LightjamsSpout is a C++ project, I can’t understand how to use it, and the version is relatively old and not suitable
  2. The C# project of SpoutCSharp seems to also call a third-party SharpDX class library. I don’t know where to download and use this thing. Please complete the project introduction.
  3. I have studied the Spout.NET project before and it is the only project that can be run, but it lacks the Receiver.

These projects can only be maintained by the individual authors. Although they are old now, you might get a response if you ask from the repository…

You can download SharpDX from the GitHub repository.

我现在用c#的wpf程序,需要读取到spout2的图片帧并输出到窗体, 现在我已经能获取到spout2的字节流了

var m_glContext = new GLContext();


LightjamsSpoutReceiver m_receiver = new LightjamsSpoutReceiver();
int m_width, m_height;
// the senderName as retrieved when enumerating senders or "" to use the active sender
m_receiver.Connect("VTubeStudioSpout", out m_width, out m_height);

const int bytesPerPixel = 3;    // RGB
int stride = 4 * ((m_width * bytesPerPixel + 3) / 4);
byte[] m_buffer = new byte[stride * m_height];

System.Drawing.Bitmap m_bitmap = new System.Drawing.Bitmap(m_width, m_height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
int i = 0;
while (i <= 100)
    m_receiver.ReceiveImage(m_buffer, LightjamsSpoutLib.EPixelFormat.BGR);
    var data = m_bitmap.LockBits(new System.Drawing.Rectangle(0, 0, m_width, m_height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
    System.Runtime.InteropServices.Marshal.Copy(m_buffer, 0, data.Scan0, m_buffer.Length);
    // 将BitmapImage设置到Image控件上
    imageControl.Source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(


Please use Google Translate and post in English here so that members can read the post .

Is there a complete example of calling SharpDX after spout reads the image frame? I searched a lot of information on github and the Internet, but none of it is complete.

I am currently using a c# wpf program and need to read the picture frames of spout2 and output them to the form. Now I can get the byte stream of spout2.

Sorry that I am not familiar with C# wpf and can’t provide an answer to this.

m_receiver.ReceiveImage(m_buffer, LightjamsSpoutLib.EPixelFormat.RGB);


Translation -

I have completed the final effect, but there is a problem with the LightjamsSpout tool. The program will crash after a few seconds. I troubleshooted the code and found that it was in
m_receiver.ReceiveImage(m_buffer, LightjamsSpoutLib.EPixelFormat.RGB);
The image frames are received in a loop for a long time, which will cause the program to crash.

The Spout.NET class library does not have any receiver examples. Is there any official complete example?

I can’t read all the details in your images and can only suggest to check that the buffer is the right size, RGB or RGBA. I will reply to your other post regarding the Spout.NET project.