I've built libwebp.dll
for WebP, using these instructions (I downloaded this source code)
I've added the libwebp.dll
file to the bin
folder of my project.
I then added this code (found here):
Private Declare Function WebPEncodeBGRA Lib "libwebp.dll" (ByVal rgba As IntPtr, ByVal width As Integer, ByVal height As Integer, ByVal stride As Integer, ByVal quality_factor As Single, ByRef output As IntPtr) As Integer
Private Declare Function WebPFree Lib "libwebp.dll" (ByVal p As IntPtr) As Integer
Private Sub Encode()
Dim source As Bitmap = New Bitmap(Server.MapPath("images\") + "audio.png")
Dim data As BitmapData = source.LockBits(New Rectangle(0, 0, source.Width, source.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
Dim webp_data As IntPtr
Dim i As Integer = WebPEncodeBGRA(data.Scan0, source.Width, source.Height, data.Stride, 80, webp_data)
WebPFree(webp_data)
End Sub
I get the error:
An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
What I also did (after comments from Dai below):
- I built the dll for a 64-bit architecture like so:
nmake /f Makefile.vc CFG=release-dynamic RTLIBCFG=dynamic OBJDIR=output ARCH=x64
(also see here) - I checked IIS for the application pool in question and it has the property
Enable32-Bit Applications
set toFalse
- I'm running Windows 10 64 bit
- Both
Environment.Is64BitProcess
andEnvironment.Is64BitOperatingSystem
in code-behind evaluate asTrue
How can I encode the image and save the encoded image to disk in WebP format?
This is the image file I'm using:
libwebp.dll
. – GenieEnable32-Bit Applications
set toFalse
, so I guess that's not it either... – Canty