截取整个桌面
- 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;
- }
本文提供了一段使用C#语言实现的代码片段,用于截取整个桌面和指定区域的截图。包括详细步骤和代码实现,适用于Windows环境下的桌面截图需求。
1279

被折叠的 条评论
为什么被折叠?



