GDI+ versions?

David Webber 136 Reputation points
2020-08-20T15:45:47.08+00:00

Still on my learning curve for using metafiles, I'm now drawing one with GDI+, using the GDI+ Metafile class.

But I want antialiasing, and for that, I believe, I have to call (one of the overloads of) Metafile::ConvertToEmfPlus( ).

These only exist in a recent version of GDI+ . The header file for class Metafile goes:

#if (GDIPVER >= 0x0110)
    Status ConvertToEmfPlus(
        IN const Graphics* refGraphics,
        IN OUT INT* conversionFailureFlag = NULL,
        IN EmfType emfType = EmfTypeEmfPlusOnly,
        IN const WCHAR* description = NULL
    );
...

Now the version of GDI+ I am using, apparently has GDIPVER < 0x0110, so this method is not available to me.

I suspect this is just the SDK, as I understand that GDI+ is part of a standard Windows installation these days, and I keep up-to-date with my Windows 10 updates. (And I'm using Visual Studio 2019, which I also keep updated).

So two questions if I may:

  1. What do I have to do to update GDI+ ?
  2. Should I?

The second question is because my application will be used by some people under Windows 7, and their built-in GDI+ may well, I suspect, be the earlier version.

Dave

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,764 questions
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 85,956 Reputation points
    2020-08-20T16:31:10.28+00:00

    To compile, add before headers :

    #define GDIPVER 0x0110
    

    All recent OS (>= Vista) have GDIPlus 1.1

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. David Webber 136 Reputation points
    2020-08-20T17:42:55.393+00:00

    One again, great - thanks. [ Rhetorically: did GDI+ 1.1 really come in in Vista - time goes by so quickly these days! ]

    I had to put the definition at the start of my stdafx.h file, as anywhere later and it had already defined GDIPVER though I haven't found where!

    I don't know if there's any protocol about answering perfect answers here, but I feel it may help others reading this, so here goes. I am trying to draw dialogue buttons with EMF images to facilitate high DPI. The problem is that at standard DPI, the vector graphics on small buttons look horrible. As a test case (at standard 96dpi) I've created a 'help' image. The code which draws it is:

    void CEmfButton::emfGrfImage( HDC hDC, const RECT &rct, HENHMETAFILE hEmf ) const  
    {  
    	Metafile     mfile( hEmf, FALSE );  
      
    	Graphics     Gr( hDC );  
    	Gr.SetSmoothingMode( SmoothingModeAntiAlias );  
      
    	#if( GDIPVER >= 0x0110 )  
    	{  
    		BOOL	 bSuccess = FALSE;  
    		EmfType	 emftype  = EmfTypeEmfPlusOnly;    
    		CStringW sDescription( L"" );  
      
    		Status sta = mfile.ConvertToEmfPlus( &Gr, &bSuccess, emftype, (LPCWSTR)sDescription );  
    	}  
    	#endif  
      
    	int x = rct.left;  
    	int y = rct.top;  
    	int w = rct.right  - rct.left + 1;  
    	int h = rct.bottom - rct.top  + 1;  
      
    	Rect rect( x, y, w, h );  
      
    	Gr.DrawImage( &mfile, rect );  
    	return;  
    }  
    

    where my CEmfButton is derived from CButton and this is called by the DrawItem() method of the owner-draw button.

    Without the #if section the button is drawn without antialiasing: 19198-help-gdiplus-no-conversion.png

    With the #if section it is antialaised: 19175-help-gdiplus-antialias.png

    And I am, as they say, a happy bunny!

    Dave

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.