我正在尝试将 HBITMAP 转换为 Gdiplus 位图。我的代码正在获取我从谷歌找到的一些代码的屏幕截图并将其放入 HBITMAP。我想使用 Gdiplus 获取 rgb 值(特别是 argb)。
获取屏幕截图的代码工作文件,但是将 HBITMAP 转换为位图的行会引发大量疯狂的链接器错误。这是我的代码:
HDC hScreenDC = CreateDC((LPCWSTR)"DISPLAY", NULL, NULL, NULL);
// and a device context to put it in
HDC hMemoryDC = CreateCompatibleDC(hScreenDC);
int x = GetDeviceCaps(hScreenDC, HORZRES);
int y = GetDeviceCaps(hScreenDC, VERTRES);
// maybe worth checking these are positive values
HBITMAP hBitmap = CreateCompatibleBitmap(hScreenDC, x, y);
// get a new bitmap
HBITMAP hOldBitmap = (HBITMAP)SelectObject(hMemoryDC, hBitmap);
BitBlt(hMemoryDC, 0, 0, 1920, 1080, hScreenDC, 0, 0, SRCCOPY);
hBitmap = (HBITMAP)SelectObject(hMemoryDC, hOldBitmap);
// clean up
DeleteDC(hMemoryDC);
DeleteDC(hScreenDC);
Gdiplus::Bitmap* pBitmap = Gdiplus::Bitmap::FromHBITMAP( hBitmap, NULL ); // <-- problem line
班轮错误是 LNK2019 并说:错误 2 错误 LNK2019:未解析的外部符号 _GdipFree@4 在函数“public: static void __cdecl Gdiplus::GdiplusBase::operator delete(void *)”中引用 (??3GdiplusBase@Gdiplus@@萨克斯@Z)
我已包含 gdiplus.h、windows.h 和 #define GDIPVER 0x110
知道如何解决这个问题吗?