文件名称:C# 屏幕截图,支持区域截图
文件大小:6.65MB
文件格式:ZIP
更新时间:2016-10-07 08:27:47
C# Capture
C# 屏幕截图,支持区域截图 public static Image CaptureScreen() { return CaptureWindow(User32.GetDesktopWindow()); } public static Image CaptureWindow(IntPtr handle) { IntPtr hdcSrc = User32.GetWindowDC(handle); RECT windowRect = new RECT(); User32.GetWindowRect(handle, ref windowRect); int width = windowRect.right - windowRect.left; int height = windowRect.bottom - windowRect.top; IntPtr hdcDest = Gdi32.CreateCompatibleDC(hdcSrc); IntPtr hBitmap = Gdi32.CreateCompatibleBitmap(hdcSrc, width, height); IntPtr hOld = Gdi32.SelectObject(hdcDest, hBitmap); Gdi32.BitBlt(hdcDest, 0, 0, width, height, hdcSrc, 0, 0, SRCCOPY); Gdi32.SelectObject(hdcDest, hOld); Gdi32.DeleteDC(hdcDest); User32.ReleaseDC(handle, hdcSrc); Image image = Image.FromHbitmap(hBitmap); Gdi32.DeleteObject(hBitmap); return image; }
【文件预览】:
ScreenShot
----ScreenShot.sln(920B)
----ScreenShot.v11.suo(36KB)
----ScreenShot()
--------bin()
--------frmMain.Designer.cs(7KB)
--------ScreenShot.csproj(4KB)
--------Program.cs(535B)
--------obj()
--------ControlExtensions.cs(402B)
--------Resources()
--------Gdi32.cs(966B)
--------ShotAPI.cs(1KB)
--------frmMain.cs(765B)
--------App.config(187B)
--------frmMain.resx(6KB)
--------Properties()
--------User32.cs(841B)