Пример #1
0
        /// <summary>
        ///     Create a screenshot relativ to a <see cref="Control"/> in a rectangle focus.
        /// </summary>
        /// <param name="ctrl">
        ///     Relativ to this <see cref="Control"/>.
        /// </param>
        /// <param name="screenshotArea">
        ///     Screenshot area.
        /// </param>
        /// <returns>
        ///     A <see cref="Bitmap"/> of the captured area.
        /// </returns>
        public static Bitmap CreateRelativeToControl(Control ctrl, Rectangle screenshotArea)
        {
            Point     leftTopP  = ctrl.PointToScreen(new Point(screenshotArea.Left, screenshotArea.Top));
            Rectangle r         = new Rectangle(leftTopP.X + 1, leftTopP.Y + 1, screenshotArea.Width - 1, screenshotArea.Height - 1);
            Bitmap    bmpScreen = ScreenShot.Create(r);

            return(bmpScreen);
        }
Пример #2
0
        /// <summary>
        ///     Create a complete screenshot of a window by using a handle.
        /// </summary>
        /// <param name="windowHandle">
        ///     Handle of the window.
        /// </param>
        /// <returns>
        ///     A <see cref="Bitmap"/> of the window.
        /// </returns>
        public static Bitmap Create(IntPtr windowHandle)
        {
            Rect window;

            NativeWin32.GetWindowRect(windowHandle, out window);
            int       winWidth   = Convert.ToInt32(window.Right - window.Left);
            int       winHeight  = Convert.ToInt32(window.Bottom - window.Top);
            Rectangle windowRect = new Rectangle((int)window.Left, (int)window.Top, winWidth, winHeight);
            Bitmap    bmpScreen  = ScreenShot.Create(windowRect);

            return(bmpScreen);
        }
Пример #3
0
        /// <summary>
        ///     Create a complete screenshot of a window by using a handle.
        /// </summary>
        /// <param name="windowHandle">
        ///     Handle of the window.
        /// </param>
        /// <returns>
        ///     A <see cref="Bitmap"/> of the window.
        /// </returns>
        public static Bitmap Create(IntPtr windowHandle)
        {
            Rect window;

            User32.GetWindowRect(windowHandle, out window);
            int       winWidth   = window.Right - window.Left;
            int       winHeight  = window.Bottom - window.Top;
            Rectangle windowRect = new Rectangle(window.Left, window.Top, winWidth, winHeight);
            Bitmap    bmpScreen  = ScreenShot.Create(windowRect);

            return(bmpScreen);
        }
Пример #4
0
 /// <summary>
 ///     Create a screenshot of the primary screen.
 /// </summary>
 /// <returns>
 ///		<see cref="Bitmap"/> of captured screen.
 ///	</returns>
 public static Bitmap Create()
 {
     return(ScreenShot.Create(Screen.PrimaryScreen.Bounds));
 }