System.Drawing.Rectangle.Round C# (CSharp) Method

Round() public static method

Converts a RectangleF to a Rectangle by performing a round operation on all the coordinates.
public static Round ( RectangleF value ) : Rectangle
value RectangleF
return Rectangle
        public static Rectangle Round(RectangleF value) =>
            new Rectangle(
                (int)Math.Round(value.X),
                (int)Math.Round(value.Y),
                (int)Math.Round(value.Width),
                (int)Math.Round(value.Height));

Same methods

Rectangle::Round ( System value ) : System.Drawing.Rectangle

Usage Example

Example #1
0
        private void btnImgsrch_Click(object sender, RoutedEventArgs e)
        {
            IntPtr findwindow = FindWindow(null, AppName);

            if (findwindow != IntPtr.Zero)
            {
                //플레이어를 찾았을 경우
                lblState.Content = "찾았습니다.";

                //찾은 플레이어를 바탕으로 Graphics 정보를 가져옵니다.
                Graphics Graphicsdata = Graphics.FromHwnd(findwindow);

                //찾은 플레이어 창 크기 및 위치를 가져옵니다.
                Rectangle rect = Rectangle.Round(Graphicsdata.VisibleClipBounds);

                //플레이어 창 크기 만큼의 비트맵을 선언해줍니다.
                Bitmap bmp = new Bitmap(rect.Width, rect.Height);

                //비트맵을 바탕으로 그래픽스 함수로 선언해줍니다.
                using (Graphics g = Graphics.FromImage(bmp))
                {
                    //찾은 플레이어의 크기만큼 화면을 캡쳐합니다.
                    IntPtr hdc = g.GetHdc();
                    PrintWindow(findwindow, hdc, 0x2);
                    g.ReleaseHdc(hdc);
                }

                // pictureBox1 이미지를 표시해줍니다.
                printImg(bmp, imgPrint);
                printImg(srcImg, imgSrcPrint);

                searchIMG(bmp, srcImg);
            }
        }
All Usage Examples Of System.Drawing.Rectangle::Round