babalae/better-genshin-impact · error · Exception

BitBlt only support 24 or 32 bit pixel color

Error message

BitBlt only support 24 or 32 bit pixel color

What it means

Thrown when the window DC reports a BITSPIXEL device cap other than 24 or 32 — the display is running at an unsupported color depth (e.g. 16-bit or 8-bit). BitBltSession only handles 24/32-bit pixel formats because the DIB section is created with biBitCount=24.

Source

Thrown at Fischless.GameCapture/BitBlt/BitBltSession.cs:78

        Height = h;

        lock (_lockObject)
        {
            try
            {
                _hdcSrc = User32.GetDC(_hWnd);
                if (_hdcSrc.IsInvalid) throw new Exception($"Failed to get DC for {_hWnd}");

                var hdcRasterCaps = Gdi32.GetDeviceCaps(_hdcSrc, Gdi32.DeviceCap.RASTERCAPS);
                if ((hdcRasterCaps | 1) == 0) // RC_BITBLT
                    // 设备不支持 BitBlt
                    throw new Exception("BitBlt not supported");

                var hdcSrcPixel = Gdi32.GetDeviceCaps(_hdcSrc, Gdi32.DeviceCap.BITSPIXEL);
                // 颜色位数
                if (hdcSrcPixel != 32 && hdcSrcPixel != 24)
                    // 目前只考虑支持24/32位像素格式
                    throw new Exception("BitBlt only support 24 or 32 bit pixel color");

                var hdcSrcPlanes = Gdi32.GetDeviceCaps(_hdcSrc, Gdi32.DeviceCap.PLANES);
                // 颜色平面数
                if (hdcSrcPlanes > 1)
                    // 意味着色深不是标准色深
                    throw new Exception("BitBlt only support 1 plane");

                var hdcClip = Gdi32.GetDeviceCaps(_hdcSrc, Gdi32.DeviceCap.CLIPCAPS);
                if (hdcClip == 0)
                    // 设备不支持剪切出单一窗口
                    throw new Exception("Device does not support clipping");

                _hdcDest = Gdi32.CreateCompatibleDC(_hdcSrc);
                if (_hdcDest.IsInvalid)
                {
                    Debug.Fail("Failed to create CompatibleDC");
                    throw new Exception($"Failed to create CompatibleDC for {_hWnd}");
                }

View on GitHub (pinned to a7cb36712d)

Solutions

  1. Set the display color depth to 32-bit (Highest / True Color 32bit) in Windows display settings.
  2. For RDP, configure the session to use 32-bit color depth.
  3. Switch capture mode from BitBlt to GraphicsCapture or DXGI, which are color-depth agnostic.
Defensive patterns

Strategy: validation

Validate before calling

var bitsPixel = Gdi32.GetDeviceCaps(hdc, Gdi32.DeviceCap.BITSPIXEL);
if (bitsPixel != 24 && bitsPixel != 32)
    return CaptureMode.UnsupportedColorDepth; // fall back to GraphicsCapture/DXGI

Prevention

When it happens

Trigger: The user's monitor/display is set to 16-bit (High Color) or 8-bit color depth; an RDP session forces reduced color depth; a virtual GPU driver reports a nonstandard depth.

Common situations: Windows display set to 16-bit color; RDP configured for 16-bit color mode; certain virtual display adapters / remote tools that lower color depth.

Related errors


AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13). Data as JSON: /api/errors/0b6522e339c34102. Report an issue: GitHub.