截取整个桌面
- public static Image Cut()
- {
- Rectangle rc = Screen.PrimaryScreen.Bounds;
- int iWidth = rc.Width;
- int iHeight = rc.Height;
- Image myImage = new Bitmap(iWidth, iHeight);
- Graphics.FromImage(myImage).CopyFromScreen(new System.Drawing.Point(0, 0), new System.Drawing.Point(0, 0), new System.Drawing.Size(iWidth, iHeight));
- return myImage;
- }
截取一个Rectangle.
- public static Image Cut(Rectangle rect)
- {
- Rectangle rc = rect;
- int iWidth = rc.Width;
- int iHeight = rc.Height;
- Image myImage = new Bitmap(iWidth, iHeight);
- Graphics.FromImage(myImage).CopyFromScreen(rc.Location, new System.Drawing.Point(0, 0), new System.Drawing.Size(iWidth, iHeight));
- return myImage;
- }
截取 x,y 点 weight,height
- public static Image Cut(int X, int Y, int Width, int Height)
- {
- Rectangle rc = new Rectangle(X, Y, Width, Height);
- int iWidth = rc.Width;
- int iHeight = rc.Height;
- Image myImage = new Bitmap(iWidth, iHeight);
- Graphics.FromImage(myImage).CopyFromScreen(rc.Location, new System.Drawing.Point(0, 0), new System.Drawing.Size(iWidth, iHeight));
- return myImage;
- }