/// <summary> /// Build an ImageAdapter based on a Window handler /// </summary> /// <param name="Hwnd">The handle to window</param> /// <param name="clientAreaOnly">bool to capture the client are only, true to capture the whole window</param> public ImageAdapter(IntPtr Hwnd, bool clientAreaOnly) { using (Bitmap bmp = ImageUtility.CaptureScreen(Hwnd, clientAreaOnly)) { InternalConstructor(bmp); } }
/// <summary> /// Build an ImageAdapter based on an area of the screen /// </summary> /// <param name="screenAreaToCapture">The area to capture (in screen coordinate) on the screen</param> public ImageAdapter(System.Drawing.Rectangle screenAreaToCapture) { using (Bitmap bmp = ImageUtility.CaptureScreen(screenAreaToCapture)) { InternalConstructor(bmp); } }
/// <summary> /// Returns a bitmap of the screen /// </summary> /// <param name="rectangle">Position of the Screen to take the Capture of</param> /// <returns>Returns the Bitmap of the screen</returns> public SerializableBitmap CaptureScreen(Rectangle rectangle) { Bitmap clientarea = ImageUtility.CaptureScreen(hwnd, true, false); Bitmap bmp = ImageUtility.ClipBitmap(clientarea, rectangle); return(new SerializableBitmap(bmp)); }
private Bitmap SnapshotRect(System.Drawing.Rectangle rect) { // Allow user to do whatever just before snapshot (Hover, click, presskey, ...) if (BeforeSnapshot != null) { BeforeSnapshot(this, new DoWorkEventArgs(_counter)); } // Take Snapshot Microsoft.Test.Logging.GlobalLog.LogStatus("Capturing rect : " + rect.ToString()); return(ImageUtility.CaptureScreen(rect)); }
private Bitmap SnapshotWindow(IntPtr hwnd) { // Allow user to do whatever just before snapshot (Hover, click, presskey, ...) if (BeforeSnapshot != null) { BeforeSnapshot(this, new DoWorkEventArgs(_counter)); } // Take Snapshot Microsoft.Test.Logging.GlobalLog.LogStatus("Taking snapshot"); return(ImageUtility.CaptureScreen(hwnd, true)); }
/// <summary> /// API Called back by _timer to take the screen snapshot /// </summary> /// <param name="sender">(object) the timer that called it</param> /// <param name="e">(ElapsedEventArgs) Data from timer event </param> private void TakeSnapshot(object sender, ElapsedEventArgs e) { // Note : Glitch might occur if: // * Cannot take snapshot fast enough (Frequency too hight and/or Area too large) // * User do something else simultaneously (WM_TIMER is a low priority message, if CPU does something else, timer message will be delayed) if (_throwOnGlitch) { double interval = DateTime.Now.Subtract(e.SignalTime).TotalMilliseconds; if (interval > _interval) { throw new RenderingVerificationException("Glitch - this configuration do not support what you specified -- Try a snaller area and/or a lower frequency"); } } _frames.Add(ImageUtility.CaptureScreen(_area)); }