Why does GetObject return an BITMAP with null bmBits?

后端 未结 4 2215
南笙
南笙 2021-02-14 02:09

Context: I\'m trying to take a screenshot of another window to feed it into OpenCV. I found some code on the web that should be able to convert a BITMAP to something OpenCV can

4条回答
  •  礼貌的吻别
    2021-02-14 02:37

    The bmBits member is non-null for DIB sections. For device-dependent bitmaps (such as the one you're creating), the bmBits is not set because the pixels are on the video card, not in main memory.

    In your example, you need to change CreateCompatibleBitmap to CreateDIBSection if you want direct access to the bits.

提交回复
热议问题