Menu

#1923 Use GdiAlphaBlend instead of AlphaBlend

Bug
closed-fixed
nobody
5
2023-05-31
2017-03-22
mberchtold
No

Problem
If AlphaBlend (from msimg32.dll) is used and the Scintilla dll is loaded with:
::LoadLibraryExW(L"Scintilla.dll", nullptr, LOAD_LIBRARY_SEARCH_APPLICATION_DIR);
LoadLibrary fails with ERROR_MOD_NOT_FOUND
If LoadLibraryExW without the LOAD_LIBRARY_SEARCH_APPLICATION_DIR flag is used, it succeeds.

Cause
I have no idea what the cause is and it seems a rather unexpected behavior.

Solution
Using GdiAlphaBlend instead of AlphaBlend solves this issue

I believe the AlphaBlend API inside of msimg32.dll is just a wrapper which calls GdiAlphaBlend. But this needs to be confirmed.

But an undisputable benefit of using GdiAlphaBlend is that you don't need the extra dependency to msimg32.dll

I have attached a patch but it may be easier just to replace AlphaBlend with GdiAlphaBlend (and remove the msimg32.lib from the project)

1 Attachments

Discussion

  • Neil Hodgson

    Neil Hodgson - 2017-03-22

    GdiAlphaBlend isn't available when building with MinGW GCC.

    Since msimg32.dll is a system DLL, it will be available if Scintilla is loaded with the flag that allows system DLLs:

    ::LoadLibraryExW(L"Scintilla.dll", nullptr,
         LOAD_LIBRARY_SEARCH_APPLICATION_DIR|LOAD_LIBRARY_SEARCH_SYSTEM32);
    

    Scintilla may, in the future, use other system DLLs so LOAD_LIBRARY_SEARCH_SYSTEM32 should be used.

    Attached is a patch that extends the proposed patch by removing msimg32 from make and project files.

     
  • mberchtold

    mberchtold - 2017-03-22

    Thank you. I have incorrectly assumed that system dll dependencies will be loaded from the system32 folder, even when the LOAD_LIBRARY_SEARCH_SYSTEM32 is not present.

    The patch for MinGW here mentions that GdiAlphaBlend and co have been added to the headers:
    https://sourceforge.net/p/mingw-w64/patches/59/

     

    Last edit: mberchtold 2017-03-22
    • Neil Hodgson

      Neil Hodgson - 2017-03-23

      Mingw-w64 is a fork from MinGW and (MinGW) does not have GdiAlphaBlend. The two projects differ in their approach to adding new system APIs to headers.

       

      Last edit: Neil Hodgson 2017-03-23
  • Zufu Liu

    Zufu Liu - 2023-03-26
    • labels: --> win32, mingw
     
  • Neil Hodgson

    Neil Hodgson - 2023-03-27
    • labels: win32, mingw --> win32, mingw, scintilla
    • status: open --> open-fixed
     
  • Neil Hodgson

    Neil Hodgson - 2023-03-27

    Committed change as [04ed59].

     

    Related

    Commit: [04ed59]

  • Neil Hodgson

    Neil Hodgson - 2023-05-31
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB