private static void SendFrame(byte[] encodedImageBytes, Rectangle diffArea, Viewer viewer, SemaphoreSlim sendFramesLock) { _ = Task.Run(async() => { try { if (encodedImageBytes.Length == 0) { return; } await viewer.SendScreenCapture(new CaptureFrame() { EncodedImageBytes = encodedImageBytes, Top = diffArea.Top, Left = diffArea.Left, Width = diffArea.Width, Height = diffArea.Height, }); } finally { sendFramesLock.Release(); } }); }
private void SendFrame(Bitmap diffImage, Viewer viewer, SemaphoreSlim sendFramesLock) { _ = Task.Run(async() => { try { var encodedImageBytes = ImageUtils.EncodeGif(diffImage); if (encodedImageBytes?.Length > 0) { var frames = new List <CaptureFrame>() { new CaptureFrame() { EncodedImageBytes = encodedImageBytes, Top = 0, Left = 0, Width = diffImage.Width, Height = diffImage.Height, } }; await viewer.SendScreenCapture(frames); } } finally { sendFramesLock.Release(); diffImage.Dispose(); } }); }
private static void SendFrame(Bitmap currentFrame, Rectangle diffArea, Viewer viewer, SemaphoreSlim sendFramesLock) { _ = Task.Run(async() => { try { using var newImage = currentFrame.Clone(diffArea, PixelFormat.Format32bppArgb); var encodedImageBytes = ImageUtils.EncodeBitmap(newImage, viewer.EncoderParams); if (encodedImageBytes?.Length > 0) { await viewer.SendScreenCapture(new CaptureFrame() { EncodedImageBytes = encodedImageBytes, Top = diffArea.Top, Left = diffArea.Left, Width = diffArea.Width, Height = diffArea.Height, }); } } finally { sendFramesLock.Release(); currentFrame.Dispose(); } }); }
private void SendFrames(Bitmap currentFrame, List <Rectangle> diffAreas, Viewer viewer, SemaphoreSlim sendFramesLock) { _ = Task.Run(async() => { try { foreach (var diffArea in diffAreas) { using var newImage = currentFrame.Clone(diffArea, PixelFormat.Format32bppArgb); if (viewer.Capturer.CaptureFullscreen) { viewer.Capturer.CaptureFullscreen = false; } var encodedImageBytes = ImageUtils.EncodeBitmap(newImage, viewer.EncoderParams); if (encodedImageBytes?.Length > 0) { await viewer.SendScreenCapture(encodedImageBytes, diffArea.Left, diffArea.Top, diffArea.Width, diffArea.Height); } } } finally { sendFramesLock.Release(); currentFrame.Dispose(); } }); }
private static void SendFrame(Bitmap clone, Rectangle diffArea, Viewer viewer, SemaphoreSlim sendFramesLock) { _ = Task.Run(async() => { try { var encodedImageBytes = ImageUtils.EncodeJpg(clone, viewer.EncoderParams); if (encodedImageBytes.Length == 0) { return; } await viewer.SendScreenCapture(new CaptureFrame() { EncodedImageBytes = encodedImageBytes, Top = diffArea.Top, Left = diffArea.Left, Width = diffArea.Width, Height = diffArea.Height, }); } finally { sendFramesLock.Release(); clone.Dispose(); } }); }
private static async Task SendFrame(byte[] encodedImageBytes, Rectangle diffArea, Viewer viewer) { if (encodedImageBytes.Length == 0) { return; } await viewer.SendScreenCapture(new CaptureFrame() { EncodedImageBytes = encodedImageBytes, Top = diffArea.Top, Left = diffArea.Left, Width = diffArea.Width, Height = diffArea.Height, }); }