I unable to use GDI+ 1.1 classes in my VS2012 MFC C++ project (on Win7). Classes Image, Bitmap, Graphics works just fine but when I try to declare an object of Blur class (or other v1.1 classes) I am getting an error C2065: ‘Blur’: undeclared identifier
. I tried to define GDIPVER
(in stdafx.h) like this
#define GDIPVER 0x0110 //also I get the warning C4005: 'GDIPVER' : macro redefinition
#include <gdiplus.h>
#pragma comment (lib,"Gdiplus.lib")
but it does not work.
How to turn on GDI+ 1.1 instead of 1.0?
I fought with a similar issue for a while on one project. For me, my precompiled header has this:
#define GDIPVER 0x0110 // Use more advanced GDI+ features
but the precompiled header does not #include "gdiplus.h". That only occurs in the .cpp files which actually make GDI+ calls. I forward declare GDI+ classes for the headers which have GDI+ object pointers as members. As Hans and other comments noted, there's probably another header including gdiplus.h before the GDIPVER is set. To figure out where it's included try going to the C/C++ > Command Line settings for your project and add /showIncludes then do a full build and look in the build log for gdiplus.h and track back to the first header including it.
Once you clear that hurdle, I also discovered my application would not actually use the 1.1 features unless the manifest was also updated. So one of my .cpp files has this:
// Update Manifest
// cf: http://blogs.msdn.com/b/oldnewthing/archive/2007/05/31/2995284.aspx
//
// We use features from GDI+ v1.1 which is new as of Windows Vista. There is no redistributable for Windows XP.
// This adds information to the .exe manifest to force GDI+ 1.1 version of gdiplus.dll to be loaded on Vista
// without this, Vista defaults to loading version 1.0 and our application will fail to launch with missing entry points.
#if 64BIT_BUILD
#pragma comment(linker, "\"/manifestdependency:type='Win32' name='Microsoft.Windows.GdiPlus' version='1.1.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
#pragma comment(linker, "\"/manifestdependency:type='Win32' name='Microsoft.Windows.GdiPlus' version='1.1.0.0' processorArchitecture='X86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With