Eli Zaretskii writes: >> From: Juan José García-Ripoll >> >> I believe something similar can be done for Windows using GDI+, removing >> the dependency on libpng, libjpeg and libtiff. Would that be ok or >> interesting? Has anyone tried it before? > > Please point to the relevant APIs, to make the discussion more > practical. GDI+ is an evolution of GDI that supports arbitrary plug-ins for image formats, both bitmaps and vector type. It is a bit more modern than GDI, from what I get, but, just as GDI, it is not the modern standard for Windows 2D displays. Indeed, it is old enough that it is also supported by Windows XP. https://docs.microsoft.com/en-us/windows/win32/gdiplus/-gdiplus-gdi-start GDI+ has a flat C interface that allows loading images, querying properties, displaying them and converting them to older GDI formats. https://docs.microsoft.com/en-us/windows/win32/gdiplus/-gdiplus-flatapi-flat This interface is included with the Mingw64/32 headers. I propose to use this last feature. I attach a patch that works with Emacs 28 (and probably also Emacs 27). The way it works: - At configuration time, it works just as the NextStep (NS) system, disabling the use of libpng, libjpeg, libtiff and libgif when the build system is Mingw. - In images such as PNG, GIF or TIFF, it currently does not use a bitmask for display. Instead, it relies on GDI+'s convertion to HBITMAP, which allows alpha blending with any background color of choice. - In the C code, it replaces the load_jpeg, load_gif, etc, with a generic w32_load_image() function in src/w32image.c. This function is heavily inspired by ns_load_image() in src/nsimage.c. The patch is not intrusive at all, I believe. It does not aim to replace Emacs's engine for displaying images and fonts on Windows. Instead, it just uses GDI+ for the conversion. The only thing that is missing is a place to call GdipShutdown(). I do not know how to add an exit handler for Emacs' C core. I have tested that the patch works with some stock JPEG, GIF, PNG and TIFF images, including multipage and transparency. I have also verified that it is possible to convert all *.xpm icons to *.png format and thus eliminate the need to include libXpm-noX.dll. Plus, the size of the icons is reduced by 50% Cheers, -- Juan José García Ripoll http://juanjose.garciaripoll.com http://quinfog.hbar.es