C#的Receiver接收器如何编码?我现在写了一个上午,找了很多网上的资料,绝少有这方面的c#代码。
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);
C#的Receiver接收器如何编码?我现在写了一个上午,找了很多网上的资料,绝少有这方面的c#代码。
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 -
1、LightjamsSpout是c++项目,我看不明白怎样使用,而且版本比较旧,不适合
2、SpoutCSharp这个C#项目看起来还调用了一个第三方的SharpDX类库,不知道这个东西在哪里下载如何使用,项目介绍补全
3、Spout.NET项目我之前已经研究过,是唯一可以跑起来的项目,但是缺少Receiver接收器
调试了一下,好像LightjamsSpout这个项目是可以的,我做了LightjamsSpout.dll编译,放入c#项目可以运行
Translation -
- LightjamsSpout is a C++ project, I can’t understand how to use it, and the version is relatively old and not suitable
- 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.
- 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.
有没有spout读取到图片帧后,调用SharpDX的完整例子,我上了github和网络搜索了很多资料,都不太完整
我现在用c#的wpf程序,需要读取到spout2的图片帧并输出到窗体, 现在我已经能获取到spout2的字节流了
var m_glContext = new GLContext();
m_glContext.Create();
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;
//Thread.Sleep(3000);
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);
m_bitmap.UnlockBits(data);
m_bitmap.Save("0.png");
// 将BitmapImage设置到Image控件上
imageControl.Source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
m_bitmap.GetHbitmap(),
IntPtr.Zero,
Int32Rect.Empty,
BitmapSizeOptions.FromEmptyOptions());
i++;
}
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.
谢谢你的技术支持,项目已经完成并且开源
开源地址:GitHub - worm128/yinmei-desktop: Ai吟美桌宠【c#/c++/spout2/directX】