Why does GetObject return an BITMAP with null bmBits?

后端 未结 4 2220
南笙
南笙 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:30

    From GetObject documentation on MSDN. Please note the second paragraph.

    If hgdiobj is a handle to a bitmap created by calling CreateDIBSection, and the specified buffer is large enough, the GetObject function returns a DIBSECTION structure. In addition, the bmBits member of the BITMAP structure contained within the DIBSECTION will contain a pointer to the bitmap's bit values.

    If hgdiobj is a handle to a bitmap created by any other means, GetObject returns only the width, height, and color format information of the bitmap. You can obtain the bitmap's bit values by calling the GetDIBits or GetBitmapBits function.

提交回复
热议问题