//針對全螢幕做截圖
private void ButtonClick(Object sender,EventArgs e){
Bitmap myImage = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
Graphics g = Graphics.FromImage(myImage);
g.CopyFromScreen(new Point(0,0),new Point(0,0),new Size(Screen.PrimaryScreen.Bounds.Width,Screen.PrimaryScreen.Bounds.Height));
IntPtr dc1 = g.GetHdc();
g.ReleaseHdc(dc1);
myImage.Save(@"C:\Screenshot.jpg");
}
//針對 Windows Form 做截圖
private void ButtonClick(Object sender, EventArgs e){
Bitmap myImage = new Bitmap(this.Width,this.Height);
Graphics g = Graphics.FromImage(myImage);
g.CopyFromScreen(new Point(this.Location.X,this.Location.Y),new Point(0,0),new Size(this.Width,this.Height));
IntPtr dc1 = g.GetHdc();
g.ReleaseHdc(dc1);
myImage.Save(@"C:\WindowsFormScreenshot.jpg");
}
2016年4月24日 星期日
C# From 截圖功能
以下用兩種截圖做為範例:
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言