2014-05-20 24 views

回答

0

適用於Windows,

ScreenCapture sc = new ScreenCapture(); 
Image img = sc.CaptureScreen(); 
this.imageDisplay.Image = img; 
sc.CaptureWindowToFile(this.Handle,"D:\\ScreenShot1.png",ImageFormat.png); 

按照鏈接實施

http://www.developerfusion.com/code/4630/capture-a-screen-shot/

+0

這抓屏類是標準庫的一部分發現

private Bitmap Screenshot() { //Create a bitmap with the same dimensions like the screen Bitmap screen = new Bitmap(SystemInformation.VirtualScreen.Width, SystemInformation.VirtualScreen.Height); //Create graphics object from bitmap Graphics g = Graphics.FromImage(screen); //Paint the screen on the bitmap g.CopyFromScreen(SystemInformation.VirtualScreen.X, SystemInformation.VirtualScreen.Y, 0, 0, screen.Size); g.Dispose(); //return bitmap object/screenshot return screen; } 

參考? –

+0

@PaoloTedesco我忘了添加鏈接,實際上它需要很少的API函數,請參考鏈接。 – Ulaga

0

我從來沒有嘗試過這個我自己,但這裏是我的similer問題在網上找到。

ScreenCapture sc = new ScreenCapture(); 
// capture the screen and stores it in a image 
Image img = sc.CaptureScreen(); 

下面是我從 Capture screenshot of active window?

得到的信息的問題,這是他們從 http://www.developerfusion.com/code/4630/capture-a-screen-shot/

希望這有助於得到的答案該網站的參考。

編輯:這是另一種方式,我發現這裏http://en.code-bude.net/2012/12/27/how-to-take-a-screenshot-in-csharp/