cwindowsgtk

GTK+ load png without loaders.cache


Is it possible to load a PNG image without using of loaders.cache file? The background is, i dont want to change / recreate the loaders.cache file on every directory change. A another option for me was to have a loaders.cache with a direct path link like this:

"libpixbufloader-png.dll"
"png" 5 "gdk-pixbuf" "PNG" "LGPL"
"image/png" ""
"png" ""
"\211PNG\r\n\032\n" "" 100

But with this, GTK+ not search in the working directory.
It was using the path C:\MinGW64\libpixbufloader-png.dll
(The working path is C:\MinGW64\bin\proj\gtk\_package\libpixbufloader-png.dll).

I tried to set g_setenv("GDK_PIXBUF_MODULEDIR", module_dir, TRUE); and g_setenv("GDK_PIXBUF_MODULE_FILE", module_dir, TRUE); to the working directory but this dont have any effect.

I use GTK 3.20.


Solution

  • I found a way to solve my question.
    I rebuild GdkPixbuf from here with following meson settings:

    meson setup _build . -Dman=false
    meson compile -C _build
    

    Copying the new libgdk_pixbuf-2.0-0.dll to my executable directory, makes it possible to load PNG images without the loaders.cache file.

    As background info:
    I installed GTK3 from this manual. The default installed libgdk_pixbuf-2.0-0.dll (2.42.11.0) was build without enabled loaders.
    The libgdk_pixbuf-2.0-0.dll I build have version 2.42.13.0 and the loaders are default enabled:

    enter image description here