免责声明:我才刚刚开始学习 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
是一个类型定义Status
in GdiPlusGpStubs.h
(C++ 头文件),以及Status
本身是一个定义在中的枚举GdiPlusTypes.h
(也是 C++ 标头)。我尝试自己定义枚举,但由于某种原因编译器不会接受它!
那么...如何在 C 中使用 GDI+ 函数呢?我应该动态加载 gdiplus.dll 吗?