I am having performance issues of rendering buffer[] to . My CPU is always running at near 100% efficiency. I tried using some ways like chopping buffer[] and then comparing, if the region changes, render that area but it doesn't work. Can someone help me with this or point me to a library that can help?
I'm working on an app that's almost like AnyDesk
Thank you very much.
Here is my code
public void KVM_VideoCallback(IntPtr p_buffer, int width, int height, int channel)
{
byte[] Buffer;
Buffer = new byte[width * height * 3];
Buffer.Initialize();
Marshal.Copy(p_buffer, Buffer, 0, (int)(width * height * 3));
imageViewVM?.UpdateNewImage(Buffer, width, height, channel);
}
public void UpdateNewImage(byte[] buffer, int width, int height, int channel)
{
lock (updateBufferHandler)
{
iwI = width;
ihI = height;
stride = width * channel;
Array.Clear(bufferCamera, 0, bufferCamera.Length);
bufferCamera = buffer;
}
isUpdate = !isUpdate;
if (isUpdate) return;
System.Windows.Application.Current.Dispatcher.Invoke(() =>
{
btmImage = BitmapSource.Create(width, height, dpi, dpi, PixelFormats.Bgr24, BitmapPalettes.Gray256, buffer, stride);
});
}