使用 GDI+ 位图
我正在使用 GDI+ 位图类将 IStream 转换为 HBITMAP。 我已将 gliplus lib 文件包含在链接器输入中,并且还在构建路径中包含了 dll。 但是使用该语句
Bitmap bm(lpStream,FALSE);
给了我一个错误C2065:'Bitmap':未声明的标识符
有人可以告诉我我在这里做错了什么。
谢谢。
编辑
我已经在我的实现中包含了适当的标头(gdiplus.h),并且我可以通过在上下文菜单中选择“转到定义”选项来查看位图的定义。
I am using GDI+ Bitmap class to convert an IStream to HBITMAP. I have included the gliplus lib file in the Linker inputs and also have the dll in the build path. But using the statement
Bitmap bm(lpStream,FALSE);
gives me an error C2065: 'Bitmap' : undeclared identifier
Can someone please tell me what I am doing wrong here.
Thanks.
Edit
I have already included the appropriate headers in my implementation (gdiplus.h) And I can view the definition of Bitmap by selecting the "Go to definition" option in the context menu.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
除了命名空间问题之外,使用 Gdiplus 还要求在使用之前初始化库:
您需要持有令牌,直到使用完 Gdiplus,然后释放它:
如果库未初始化,Gdiplus 操作将失败并出现错误 GdiplusNotInitialized。
In addition to the namespace issue, using Gdiplus also requires that the library is initialized before it is used:
You will need to hold on to the token until you are done using Gdiplus, then release it:
If the library is not initialized, Gdiplus operations will fail with the error GdiplusNotInitialized.
您还需要包含相关的头文件。 据猜测,它可能有一个类似“Bitmap.h”或“gdi+.h”的名称。
有关 Bitmap 类的更多详细信息,请参见此处。 正确的头文件是“gdiplus.h”。 简而言之:
在 MSDN 的表格中,“头”字样告诉您需要包含的头文件的名称。 您已经介绍过“导入库”。 如果您错过了这一点,您就会收到链接错误。
编辑:
在这篇有关 GDI+ 入门的文章中,看起来您需要指定一个名称空间“Gdiplus”。 使用“using namespace Gdiplus”或显式指定名称空间。
You also need to include the relevant header file. At a guess, it would probably have a name like "Bitmap.h" or "gdi+.h".
There is some more detail on the Bitmap class here. The correct header file is "gdiplus.h". In short:
In the table in MSDN, where it says "Header", this tells you the name of the header file you need to include. The "Import Library" you have already covered. Had you missed that, you would have gotten a link error.
EDIT:
In this article on getting started with GDI+, it looks like there is a namespace "Gdiplus" that you need to specify. Either use "using namespace Gdiplus" or specify the namespace explicitly.