C#에서 스크린을 캡처하는 함수입니다. 모니터의 전체 화면을 캡처해 지정한 위치에 저장합니다.




C# 화면 캡처하기

   public void CaptureImage()

        {

            try

            {      

                image_name = "이미지 이름";

                Bitmap bitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);

                Graphics g = Graphics.FromImage(bitmap);

                g.CopyFromScreen(new Point(0, 0), new Point(0, 0), new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height));

                g.Dispose();

                g = null;


                bitmap.Save(Environment.GetFolderPath( "저장할 위치" + image_name + ".png", ImageFormat.Png);

            }

            catch (Exception e)

            {

                Console.WriteLine(e);

            }

        }



'Development > C#' 카테고리의 다른 글

C# 파일 다운로드하기  (0) 2017.07.27
C# 현재시간 Timestamp 가져오는 함수  (0) 2017.07.20