예제 #1
0
        public Bitmap CaptureScreen()
        {
            Cursor    c            = null;
            Rectangle cursorBounds = Rectangle.Empty;
            IntPtr    cptr         = WinUtil.GetCurrentCursor();

            if (cptr != IntPtr.Zero)
            {
                c = new Cursor(cptr);
                int x0 = Cursor.Position.X;
                int y0 = Cursor.Position.Y;
                if (x0 < 0)
                {
                    x0 = 0;
                }
                if (y0 < 0)
                {
                    y0 = 0;
                }
                Point pos = new Point(x0, y0);
                cursorBounds = new Rectangle(pos, Cursor.Current.Size);
            }
            //===capture===
            Bitmap bmp = WinUtil.CaptureScreen();

            //===end of capture===
            if (bmp != null && c != null && cursorBounds != Rectangle.Empty)
            {
                using (Graphics g = Graphics.FromImage(bmp))
                {
                    c.Draw(g, cursorBounds);
                }
            }
            return(bmp);
        }