我试图将HBITMAP转换为Gdiplus位图。我的代码得到了一些我从google找到的代码并将其放入HBITMAP中的截图。我想要使用Gdiplus来获得rgb值(特别是argb)。Gdiplus位图错误
获取屏幕截图工作文件的代码,但将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在功能上引用的“市民:静态无效__cdecl Gdiplus :: GdiplusBase :: delete操作符(无效*)”(?? 3GdiplusBase @ Gdiplus @@ SAXPAX @ Z)
我已经包括gdiplus.h,WINDOWS.H和的#define GDIPVER量0x110
任何想法如何解决这一问题?