【发布时间】:2011-07-04 03:07:02
【问题描述】:
免责声明:我才刚刚开始使用 C,所以很可能我遗漏了一些明显的东西,或者没有正确地思考! :)
我将如何在纯 C 中使用 GDI+?
据我了解,GDI+ 已经封装了为 C++ 制作的对象,但在它下面是一个平面 API,可通过 gdiplusflat.h 访问,这是一个 C 友好的标头。
我的问题是当我#include它时,我得到以下错误:
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\gdiplusflat.h(30) : error C2143: syntax error : missing '{' before '__stdcall'
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\gdiplusflat.h(31) : error C2146: syntax error : missing ')' before identifier 'brushMode'
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\gdiplusflat.h(31) : error C2061: syntax error : identifier 'brushMode'
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\gdiplusflat.h(31) : error C2059: syntax error : ';'
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\gdiplusflat.h(31) : error C2059: syntax error : ','
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\gdiplusflat.h(31) : error C2059: syntax error : ')'
and 100 more...
现在,我认为这些错误是由于未定义 GpStatus 造成的,因为查看 GdiPlusFlat.h 表明所有函数都具有以下样式:
// WINGDIAPI is #defined as __stdcall
GpStatus WINGDIPAPI
GdipCreatePath(GpFillMode brushMode, GpPath **path);
GpStatus WINGDIPAPI
GdipCreatePath2(GDIPCONST GpPointF*, GDIPCONST BYTE*, INT, GpFillMode,
GpPath **path);
GpStatus WINGDIPAPI
GdipCreatePath2I(GDIPCONST GpPoint*, GDIPCONST BYTE*, INT, GpFillMode,
GpPath **path);
etc...
问题在于GpStatus 是GdiPlusGpStubs.h(C++ 头文件)中Status 的typedef,而Status 本身是GdiPlusTypes.h(也是C++ 头文件)中定义的枚举。我尝试自己定义枚举,但由于某种原因编译器不会接受它!
那么...如何在 C 语言中准确使用 GDI+ 函数?我应该只动态加载 gdiplus.dll 吗?
【问题讨论】: