public void CaptureByRect(Rect rect) { if (rect.IsEmpty == false) { var image = WindowSnap.GetBitmapInCoordinates((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height) as Bitmap; this.SaveImage(image); } }
protected override void OnClosing(CancelEventArgs e) { base.OnClosing(e); _windowSnap.Snapped -= Snapped; _windowSnap.Unsnapped -= Unsnapped; _windowSnap.EdgeOffsetChanged -= EdgeOffsetChanged; _windowSnap = null; }
private void TimedScreenShot(object sender, System.Timers.ElapsedEventArgs e) { if (_selectedWindow != IntPtr.Zero) { Dispatcher.Invoke((Action)(() => { image.Source = null; })); var bitmap = WindowSnap.GetWindowSnap(_selectedWindow, true).Image; Dispatcher.Invoke((Action)(() => { image.Source = BitmapToImageSource(bitmap); })); } }
protected override void OnSourceInitialized(EventArgs e) { base.OnSourceInitialized(e); // Must be called on source initialized event so the // window handle can be obtain to hook the message // proc handler properly _windowSnap = new WindowSnap(this); _windowSnap.Snapped += Snapped; _windowSnap.Unsnapped += Unsnapped; _windowSnap.EdgeOffsetChanged += EdgeOffsetChanged; }
private void CaptureArea() { this.uiWindow.HideWin(); this.captureAreaWindow.ShowCaptureArea((Rect rect) => { var image = WindowSnap.GetBitmapInCoordinates((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height) as Bitmap; // hide the current window, on complete show it back this.captureAreaWindow.HideCaptureArea(); this.uiWindow.ShowWin(); this.SaveImage(image); }); }
/// <summary> /// Captures the image. /// </summary> public void CaptureImage() { Bitmap image = null; // if the show advanced is not visible; then always capture the current area if (this.SelectedProcessItem == null || this.ShowAdvanced == false) { // capture only the background this.uiWindow.HideWin(); image = WindowSnap.GetCurrentBackgroundScreenShot() as Bitmap; this.IsApplicationVisible = true; this.uiWindow.ShowWin(); } else { var snap = WindowSnap.GetWindowSnap(this.SelectedProcessItem.WindowHandle, true); image = snap.Image; } string fileName = this.SaveImage(image as Bitmap); }
public Bitmap CaptureFrame(bool backgroundMode = true, bool cache = true) { if (this.CurrentFrame != null && cache) { this.CurrentFrame.Dispose(); } Bitmap bitmap; if (backgroundMode) { WindowSnap windowSnap = WindowSnap.GetWindowSnap(this.Handle, true); bitmap = windowSnap.Image; } else { bitmap = ForegroundCapture.CaptureWindow(this.Handle); } if (cache) { this.CurrentFrame = bitmap; } return(bitmap); }
public static int GetPixel(WindowSnap snap, int x, int y) { return(AutoSpy.ColorToInt(snap.Image.GetPixel(x, y))); }
public SnapWrapper(WindowSnap windowSnap_) { windowSnap = windowSnap_; }
public static int GetPixel(WindowSnap snap, int x, int y) { return AutoSpy.ColorToInt(snap.Image.GetPixel(x, y)); }