Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#462 GDI+: PixelFormat* broken without "using namespace Gdiplus"

closed-accepted
w32api (251)
2010-12-27
2010-10-10
Markus Koenig
No

The folks over at the Allegro project have trouble compiling their code with the GDI+ headers provided by MinGW; see this forum entry: <http://www.allegro.cc/forums/thread/605136/883924#target>. The error messages reveal that this is caused by an incorrect definition of the PixelFormat... constants in gdipluspixelformats.h. In particular, Allegro's code

if (!gdi_bmp->LockBits(&rect, Gdiplus::ImageLockModeWrite,
PixelFormat32bppARGB, gdi_lock))

expands to

if (!gdi_bmp->LockBits(&rect, Gdiplus::ImageLockModeWrite,
((PixelFormat) (...)), gdi_lock))

which, since there is a typedef Gdiplus::PixelFormat (for INT) but no namespace-less PixelFormat, breaks apart when "using namespace Gdiplus" is not being used. This patch changes the definition of all PixelFormat... constants such that the cast is done to (for simplicity) INT. An equivalent option would have been to cast to Gdiplus::PixelFormat.

A small test case is attached which can't be compiled with w32api headers from CVS but works after the patch is applied. I have also verified that all tests from <https://sourceforge.net/tracker/?func=detail&aid=3007314&group_id=2435&atid=302435> still compile and work as expected.

Discussion

  • Markus Koenig
    Markus Koenig
    2010-10-10

    Patchset

     
    Attachments
  • Markus Koenig
    Markus Koenig
    2010-10-10

    ChangeLog entry

     
    Attachments
  • Markus Koenig
    Markus Koenig
    2010-10-10

    Test case

     
    Attachments
    • assigned_to: nobody --> ir0nh34d
    • status: open --> closed-accepted
     
  • Your patch has been accepted and is now commited to CVS. You should expect to see it in the next release.