Skip to content

wrapper code for decoding animated webp #36

@thomas694

Description

@thomas694

Hello,

I'd like to contribute wrapper code for the WebPAnimDecoder API to enable decoding of Animated WebP files.

For that to work it needs the WebP DLL libwebpdemux.dll that depends on libwebp.dll. But sticking to the current way the auto switch is done and naming the file libwebpdemux_x64.dll doesn't work, because it expects to find the dependency with its original file name.
One solution is to move the files to subfolders and specify them in the DllImport attributes:

[DllImport(@"x64\libwebp.dll"]
[DllImport(@"x64\libwebpdemux.dll"]

It works and also the dependencies can be loaded. But maybe not the best solution.

The second solution uses the fact that DLLs aren't loaded into the process again if they have already been loaded before. So we can just preload the DLLs from the correct subfolder:

string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), IntPtr.Size == 4 ? "x86" : "x64");
LoadLibrary(Path.Combine(path, "libwebp.dll"));
LoadLibrary(Path.Combine(path, "libwebpdemux.dll"));

Would that be okay for you?

So first I'd like to create a PR to rename and move the DLLs to the respective subfolders.

Besides, are there any special reasons why the 32- and 64-bit version of libwebp.dll aren't used in the same version (number)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions