BrowserTools.Screenshot.CaptureWindow C# (CSharp) Метод

CaptureWindow() статический приватный Метод

static private CaptureWindow ( IntPtr hwnd, string processName ) : Bitmap
hwnd System.IntPtr
processName string
Результат System.Drawing.Bitmap
        static Bitmap CaptureWindow(IntPtr hwnd, string processName)
        {
            bool isCurrentDesktop = Utils.IsWindowOnCurrentVirtualDesktop(hwnd);

            // NOTE: We are capturing the screen area directly if the windows is on currently active virtual desktop,
            // so we must ensure that the entire window area fits the screen borders.
            if (isCurrentDesktop)
                PlaceWindowOnScreen(hwnd);

            WindowInfo wi = GetWindowInfo(hwnd, processName);

            Bitmap windowBitmap = isCurrentDesktop ?
                CaptureFromScreen(hwnd, wi) :
                PrintWindow(hwnd, wi, processName);

            Bitmap clientAreaBitmap = windowBitmap.Clone(
                new Rectangle(
                    new Point(wi.rcClient.left - wi.rcWindow.left, wi.rcClient.top - wi.rcWindow.top),
                    new Size(wi.rcClient.right - wi.rcClient.left, wi.rcClient.bottom - wi.rcClient.top)
                ),
                PixelFormat.Format32bppRgb
            );

            if (clientAreaBitmap.Size.Height == 1 && clientAreaBitmap.Size.Width == 1) {
                Console.Error.Write("Can't find the browser window");
                Environment.Exit(1);
            }

            return clientAreaBitmap;
        }