我正在使用GDI +位圖類將IStream轉換爲HBITMAP。我已經將gliplus lib文件包含在鏈接器輸入中,並且在構建路徑中也有dll。但使用語句使用GDI +位圖
Bitmap bm(lpStream,FALSE);
給我一個錯誤C2065:「位圖」:未聲明的標識符
有人能告訴我什麼,我做錯了。
謝謝。
編輯
我已經列入我的實現(gdiplus.h)相應的頭,我可以通過選擇上下文菜單中的「轉到定義」選項查看位圖的定義。
我正在使用GDI +位圖類將IStream轉換爲HBITMAP。我已經將gliplus lib文件包含在鏈接器輸入中,並且在構建路徑中也有dll。但使用語句使用GDI +位圖
Bitmap bm(lpStream,FALSE);
給我一個錯誤C2065:「位圖」:未聲明的標識符
有人能告訴我什麼,我做錯了。
謝謝。
編輯
我已經列入我的實現(gdiplus.h)相應的頭,我可以通過選擇上下文菜單中的「轉到定義」選項查看位圖的定義。
您還需要包含相關的頭文件。猜測,它可能會有一個名稱,如「Bitmap.h」或「gdi + .h」。
關於Bitmap class here有一些更多的細節。正確的頭文件是「gdiplus.h」。總之:
#include "gdiplus.h"
Constructor Information
Stock Implementation gdiplus.dll Header Declared in Gdiplusheaders.h, include gdiplus.h Import library gdiplus.lib Minimum availability GDI+ 1.0 Minimum operating systems Windows 98/Me, Windows XP, Windows 2000,
的Windows NT 4.0 SP6
在MSDN中, 「頭」,它說表,這會告訴你,你需要在頭文件的名稱包括。您已經涵蓋的「導入庫」。如果你錯過了,你會得到一個鏈接錯誤。編輯: In this article on getting started with GDI+,它看起來像有一個名稱空間「Gdiplus」,你需要指定。可以使用「使用名稱空間Gdiplus」或明確指定名稱空間。
#include <windows.h>
#include <gdiplus.h>
using namespace Gdiplus;
VOID OnPaint(HDC hdc)
{
Graphics graphics(hdc);
Pen pen(Color(255, 0, 0, 255));
graphics.DrawLine(&pen, 0, 0, 200, 100);
}
除了命名問題,使用Gdiplus還要求它在使用之前的庫已初始化:
ULONG_PTR gdiplusToken;
GdiplusStartupInput startupInput;
GdiplusStartup(&gdiplusToken, &startupInput, 0);
您將需要持有令牌,直到您使用Gdiplus完成,然後鬆開:
GdiplusShutdown(gdiplusToken);
如果該庫沒有初始化,Gdiplus操作將失敗與錯誤GdiplusNotInitialized。
嗨。我已經在課堂上加入了gdiplus.h。 Visual Studio也打開了類的定義,因此我知道標頭已被識別。但它仍然不能編譯。 – lostInTransit 2009-02-06 08:44:07