コード例 #1
0
        private static void TransmitNextFrame()
        {
            try
            {
                byte[] imageData = _screenCapture.Capture();
                ProtoClient.SendImageToServer(imageData, _screenCapture.CaptureWidth, _screenCapture.CaptureHeight);

                // Uncomment the following to enable debugging
                // MiscUtils.SaveRGBArrayToImageFile(imageData, _screenCapture.CaptureWidth, _screenCapture.CaptureHeight, AppConstants.DEBUG_IMAGE_FILE_NAME);
            }
            catch (Exception ex)
            {
                throw new Exception("Error occured during capture: " + ex.Message, ex);
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: jfmaster/HyperionScreenCap
        private static void StartCapture()
        {
            try
            {
                _d = new DxScreenCapture(Settings.MonitorIndex);

                while (_captureEnabled)
                {
                    if (!ProtoClient.IsConnected())
                    {
                        // Reconnect every 5s (default)
                        ProtoClient.Init(Settings.HyperionServerIp, Settings.HyperionServerPort,
                                         Settings.HyperionMessagePriority);
                        Thread.Sleep(Settings.ReconnectInterval);
                        continue;
                    }

                    var s  = _d.CaptureScreen(Settings.HyperionWidth, Settings.HyperionHeight, _d.MonitorIndex);
                    var dr = s.LockRectangle(LockFlags.None);
                    var ds = dr.Data;
                    var x  = RemoveAlpha(ds);

                    s.UnlockRectangle();
                    s.Dispose();
                    ds.Dispose();

                    ProtoClient.SendImageToServer(x);

                    // Add small delay to reduce cpu usage (200FPS max)
                    Thread.Sleep(Settings.CaptureInterval);
                }

                _d = null;
            }
            catch (Exception ex)
            {
                _captureEnabled = false;
                Notifications.Error("Error occured during capture: " + ex.Message);
            }
        }