我試圖將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
任何想法如何解決這一問題?