Louie De Janeiru

c# 스크린 캡쳐하기 본문

Utils

c# 스크린 캡쳐하기

Louiey 2017. 6. 27. 09:05

Graphics의 CopyFromScreen()함수가 주역


         //현재 폼 캡쳐
        private void btnCapture_Click(object sender, EventArgs e)
        {
            ScreenCapture(this.Width, this.Height, this.Location);
        }

        //Full Screen 캡쳐
        private void btnFullScreenCapture_Click(object sender, EventArgs e)
        {
            ScreenCapture(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height,
                new Point(0, 0));
        }

        //캡쳐 함수
        private void ScreenCapture(int intBitmapWidth, int intBitmapHeight, Point ptSource)
        {
            Bitmap bitmap = new Bitmap(intBitmapWidth, intBitmapHeight);
            Graphics g = Graphics.FromImage(bitmap);

            g.CopyFromScreen(ptSource, new Point(0, 0), new Size(intBitmapWidth, intBitmapHeight));

            bitmap.Save(@"D:\Test.png", ImageFormat.Png);

            picCapImage.Image = bitmap;
            picCapImage.SizeMode = PictureBoxSizeMode.StretchImage;
        }




from http://najsulman.tistory.com/m/519


'Utils' 카테고리의 다른 글

C-code 정렬  (0) 2017.08.25
EXCEL - 다른 sheet에 있는 셀의 값을 평균/MAX/MIN 취하기  (0) 2017.06.29
ST Platform에서 printf사용  (0) 2017.06.26
iar printf float 표현  (0) 2017.03.16
printf 자리수  (0) 2017.02.14