Beispiel #1
0
        private void Init()
        {
            _windowDC = User.GetWindowDC(_windowHandle);   // hdcSys
            _compatDC = Gdi.CreateCompatibleDC(_windowDC); // hdcMem

            BITMAPINFO bi = new BITMAPINFO();

            bi.bmiHeader.Init();
            bi.bmiHeader.biWidth    = _rc.Width;
            bi.bmiHeader.biHeight   = -_rc.Height;
            bi.bmiHeader.biPlanes   = 1;
            bi.bmiHeader.biBitCount = 32;

            _bitmap = Gdi.CreateDIBSection(_windowDC, ref bi, DIBColors.DIB_RGB_COLORS, out _bitmapPixels, IntPtr.Zero, 0);
            IntPtr hOldBmp = Gdi.SelectObject(_compatDC, _bitmap);

            Gdi.DeleteObject(hOldBmp);

            _mat = new Image <Bgra, byte>(_rc.Width, _rc.Height, 0, _bitmapPixels);
        }