반응형
* C# 화면 캡쳐 (Screen Capture) 예제...
-사용한 컨트롤: Button 2개, PictureBox 1개
전체 소스 코드
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace CSharp_ScreenCapture
{
public partial class Form1 : Form
{
Bitmap btMain;
public Form1()
{
InitializeComponent();
}
private void btTSC_Click(object sender, EventArgs e)
{
////Total Screen Capture
btMain = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
Screen.PrimaryScreen.Bounds.Height);
using (Graphics g = Graphics.FromImage(btMain))
{
g.CopyFromScreen(Screen.PrimaryScreen.Bounds.X,
Screen.PrimaryScreen.Bounds.Y,
0, 0,
btMain.Size,
CopyPixelOperation.SourceCopy);
//Picture Box Display
pbMain.Image = btMain;
}
}
private void btFilesave_Click(object sender, EventArgs e)
{
//File Save
if (btMain != null)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "JPG File(*.jpg) | *.jpg";
if (sfd.ShowDialog() == DialogResult.OK)
{
btMain.Save(sfd.FileName);
}
}
}
}
}
*예제 결과
- 전체 화면 캡쳐한 모습
-파일로 저장하는 모습
https://kdsoft-zeros.tistory.com/186
반응형
'C# Programming' 카테고리의 다른 글
[C#] Sendkeys - 화면 캡쳐 (Screen Capture) (0) | 2020.04.15 |
---|---|
[C#] 선택된 프로세스 죽이기 (Kill Process) (0) | 2020.04.13 |
[C#] [Control] WebBrowser 컨트롤 - 외부 IP 알아내기 (0) | 2020.04.07 |
[C#] [WMI] USB Detect 예제 (0) | 2020.04.03 |
[C#] [WMI] CPU 클럭 속도 (CurrentClockSpeed) (0) | 2020.04.01 |