private void FullCursor_Elapsed(object sender, EventArgs e) { //_gr.CopyFromScreen(0, 0, 0, 0, new System.Drawing.Size((int)_sizeScreen.X, (int)_sizeScreen.Y), CopyPixelOperation.CaptureBlt | CopyPixelOperation.SourceCopy); _bt = Native.Capture(new System.Drawing.Size((int)_sizeScreen.X, (int)_sizeScreen.Y), 0, 0); string fileName = String.Format("{0}{1}.bmp", _pathTemp, _frameCount); ListFrames.Add(new FrameInfo(fileName, FrameRate.GetMilliseconds(_snapDelay), new CursorInfo(CaptureCursor.CaptureImageCursor(ref _posCursor), OutterGrid.PointFromScreen(_posCursor), _recordClicked, _dpi))); ThreadPool.QueueUserWorkItem(delegate { AddFrames(fileName, new Bitmap(_bt)); }); Dispatcher.Invoke(() => Title = String.Format("Screen To Gif • {0}", _frameCount)); _frameCount++; }
private void Cursor_Elapsed(object sender, EventArgs e) { //Get the actual position of the form. var lefttop = Dispatcher.Invoke(() => new Point((int)((Left + 9) * _dpi), (int)((Top + 34) * _dpi))); //TODO: 2 monitors. //They share the same resolution count. Position matters. //They have different DPI. //CopyFromScreen ignores DPI. So I need to adjust the position, multiplying by the DPI scalling factor: 125%, 150%. //_size matters too. //_gr.CopyFromScreen(lefttop.X, lefttop.Y, 0, 0, _size, CopyPixelOperation.CaptureBlt | CopyPixelOperation.SourceCopy); _bt = Native.Capture(_size, lefttop.X, lefttop.Y); string fileName = String.Format("{0}{1}.bmp", _pathTemp, _frameCount); ListFrames.Add(new FrameInfo(fileName, FrameRate.GetMilliseconds(_snapDelay), new CursorInfo(CaptureCursor.CaptureImageCursor(ref _posCursor), OutterGrid.PointFromScreen(_posCursor), _recordClicked, _dpi))); ThreadPool.QueueUserWorkItem(delegate { AddFrames(fileName, new Bitmap(_bt)); }); Dispatcher.Invoke(() => Title = String.Format("Screen To Gif • {0}", _frameCount)); _frameCount++; }
private async void FullCursor_Elapsed(object sender, EventArgs e) { _captureTask = Task.Factory.StartNew(() => Native.Capture(new Size((int)_sizeScreen.X, (int)_sizeScreen.Y), 0, 0)); var bt = await _captureTask; if (bt == null || !IsLoaded) { return; } string fileName = $"{_pathTemp}{FrameCount}.png"; ListFrames.Add(new FrameInfo(fileName, FrameRate.GetMilliseconds(_snapDelay), new CursorInfo(CaptureCursor.CaptureImageCursor(ref _posCursor), OutterGrid.PointFromScreen(_posCursor), _recordClicked || Mouse.LeftButton == MouseButtonState.Pressed, _scale))); ThreadPool.QueueUserWorkItem(delegate { AddFrames(fileName, new Bitmap(bt)); }); GC.Collect(3); FrameCount++; }
private void Cursor_Elapsed(object sender, EventArgs e) { //Get the actual position of the form. var lefttop = Dispatcher.Invoke(() => new Point((int)((Left + Constants.LeftOffset) * _scale), (int)((Top + Constants.TopOffset) * _scale))); var bt = Native.Capture(_size, lefttop.X, lefttop.Y); if (bt == null || !IsLoaded) { return; } string fileName = $"{_pathTemp}{FrameCount}.png"; ListFrames.Add(new FrameInfo(fileName, FrameRate.GetMilliseconds(_snapDelay), new CursorInfo(CaptureCursor.CaptureImageCursor(ref _posCursor), OutterGrid.PointFromScreen(_posCursor), _recordClicked || Mouse.LeftButton == MouseButtonState.Pressed, _scale))); ThreadPool.QueueUserWorkItem(delegate { AddFrames(fileName, new Bitmap(bt)); }); FrameCount++; }
private async void CursorAsync_Elapsed(object sender, EventArgs e) { //Get the actual position of the form. var lefttop = Dispatcher.Invoke(() => new Point((int)((Left + Constants.LeftOffset) * _scale), (int)((Top + Constants.TopOffset) * _scale))); #region TODO: 2 monitors //They share the same resolution count. Position matters. //They have different DPI. //CopyFromScreen ignores DPI. So I need to adjust the position, multiplying by the DPI scalling factor: 125%, 150%. //_size matters too. #endregion if (_captureTask != null && !_captureTask.IsCompleted) { _captureTask.Wait(); } //var bt = await Task.Factory.StartNew(() => Native.CaptureWindow(_thisWindow, _scale)); _captureTask = Task.Factory.StartNew(() => Native.Capture(_size, lefttop.X, lefttop.Y), TaskCreationOptions.PreferFairness); var bt = await _captureTask; if (bt == null || !IsLoaded) { return; } string fileName = $"{_pathTemp}{FrameCount}.png"; if (!OutterGrid.IsVisible) { return; } ListFrames.Add(new FrameInfo(fileName, FrameRate.GetMilliseconds(_snapDelay), new CursorInfo(CaptureCursor.CaptureImageCursor(ref _posCursor), OutterGrid.PointFromScreen(_posCursor), _recordClicked || Mouse.LeftButton == MouseButtonState.Pressed, _scale))); ThreadPool.QueueUserWorkItem(delegate { AddFrames(fileName, new Bitmap(bt)); }); FrameCount++; }
private async void CursorAsync_Elapsed(object sender, EventArgs e) { //Get the actual position of the form. var lefttop = Dispatcher.Invoke(() => new Point((int)((Left + Constants.LeftOffset) * _scale), (int)((Top + Constants.TopOffset) * _scale))); if (_captureTask != null && !_captureTask.IsCompleted) { _captureTask.Wait(); } //var bt = await Task.Factory.StartNew(() => Native.CaptureWindow(_thisWindow, _scale)); _captureTask = Task.Factory.StartNew(() => Native.Capture(_size, lefttop.X, lefttop.Y), TaskCreationOptions.PreferFairness); var bt = await _captureTask; if (bt == null || !IsLoaded) { return; } string fileName = $"{_pathTemp}{FrameCount}.png"; if (!OutterGrid.IsVisible) { return; } ListFrames.Add(new FrameInfo(fileName, FrameRate.GetMilliseconds(_snapDelay), new CursorInfo(Native.CaptureImageCursor(ref _posCursor), OutterGrid.PointFromScreen(_posCursor), _recordClicked || Mouse.LeftButton == MouseButtonState.Pressed, _scale))); ThreadPool.QueueUserWorkItem(delegate { AddFrames(fileName, new Bitmap(bt)); }); FrameCount++; }