반응형

* C# 화면 캡쳐 (Screen Capture) 예제...

 

Main

 

-사용한 컨트롤: 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

 

[VBNET] 화면 캡쳐 (Screen Capture)

* VBNET 화면 캡쳐 (Screen Capture) 예제... -사용한 컨트롤: Button 2개, PictureBox 1개 전체 소스 코드 Form1.vb Public Class Form1 Dim btMain As Bitmap Private Sub btTSC_Click(ByVal sender As System...

kdsoft-zeros.tistory.com

 

반응형

+ Recent posts