Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrapper code for decoding animated webp #36

Open
thomas694 opened this issue Oct 17, 2022 · 1 comment
Open

wrapper code for decoding animated webp #36

thomas694 opened this issue Oct 17, 2022 · 1 comment

Comments

@thomas694
Copy link

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)?

@thomas694
Copy link
Author

here is a preview: wrapper code for animated WebP files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant