본문 바로가기

컴퓨터 과학 & 영상처리 관련/C# / .NET / JAVA

c# 화면캡쳐 시 영역 지정


        private void button_copyImgToClipboard_Click(object sender, EventArgs e)
        {
            Bitmap bt = new Bitmap((79)*11,79); 

            Graphics g = Graphics.FromImage(bt);
           
            Point xp = PointToScreen(new Point(picboxes[0].Location.X,0));
            Point yp = PointToScreen(new Point(0, picboxes[0].Location.Y));

 

//여기서 시작 포지션...그리고 0,0 하고 사이즈 정해주면 그 만큼 캡쳐를함

//이때 좌표를 프로세스 내 좌표를 할 지 스크린 좌표로 할 지 그것만 정하면 됨

 

            g.CopyFromScreen(
                xp.X,
                yp.Y,
                0,//this.Location.X + this.Width,
                0,//this.Location.Y + this.Height,
                new Size(bt.Width, bt.Height));
           
            //bt.Save(@"test.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
            Clipboard.SetImage((Image)bt);
            MessageBox.Show("이미지 클립보드 복사 완료");
        }