コード例 #1
0
        public Bitmap Screen(ref Rectangle bounds)
        {
            _newBitmap = CaptureScreen.CaptureDesktop();

            if (_prevBitmap != null)
            {
                // Get the bounding box.
                //
                bounds = GetBoundingBoxForChanges();
                if (bounds == Rectangle.Empty)
                {
                    // Nothing has changed.
                    //
                    return(null);
                }

                // Get the minimum rectangular area
                //
                Bitmap   diff = new Bitmap(bounds.Width, bounds.Height);
                Graphics g    = Graphics.FromImage(diff);
                g.DrawImage(_newBitmap, 0, 0, bounds, GrahicsUnit.Pixel);
                g.Dispose();

                // Set the current bitmap as the previous to prepare
                //    for the next screen capture.
                //
                _prevBitmap = _newBitmap;

                return(diff);
            }
            else
            {
                // Set the previous bitmap to the current to prepare
                //    for the next screen capture.
                //
                _prevBitmap = _newBitmap;

                // Create a bounding rectangle.
                //
                bounds = new Rectangle(0, 0, _newBitmap.Width, _newBitmap.Height);

                return(_newBitmap);
            }
        }
コード例 #2
0
 public Bitmap Cursor(ref int cursorX, ref int cursorY)
 {
     if (_newBitmap == null)
     {
         return(null);
     }
     else
     {
         Bitmap img = CaptureScreen.CaptureCursor(ref cursorX, ref cursorY);
         if (img != null && cursorX < _newBitmap.Width && cursorY < _newBitmap.Height)
         {
             return(img);
         }
         else
         {
             return(null);
         }
     }
 }