I want to respond to this
https://stackoverflow.com/questions/43101742/iwicimagingfactorycreatedecoderfromfilename-keeps-the-file-locked-even-after
this was asked in 2017, your post was in 2019, so I think Windows did have built-in support for Webp when you asked your question, unless MSWebp.dll was added later
I found MSWebp.dll in System32 using voidtools Everything (searched webp .dll) the space is intentional
opened MSWebp.dll using IDA, searched "decode", found:
CWICWebpDecoderClassFactory::`scalar deleting destructor'(uint)
then there's msdn documentation for CWICWebpDecoderClassFactory
my first hunch was to take libwebp.dll that google chrome was using, found none,
webpToClipboard_CF_DIB.ah2
viewtopic.php?f=76&t=82050&start=20#p518887
webpToHBITMAP.ah2
Code: Select all
#SingleInstance force
ListLines 0
KeyHistory 0
SendMode "Input" ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir A_ScriptDir ; Ensures a consistent starting directory.
webpToHBITMAP(webpPath) { ;on second thought, there is no "webp" in this function, maybe it can load any image codec
hModule:=DllCall("GetModuleHandleA","AStr","WindowsCodecs.dll","Ptr")||DllCall("LoadLibraryA","AStr","WindowsCodecs.dll","Ptr")
CLSID_WICImagingFactory:=Buffer(0x10)
NumPut("UInt64",0x433D5F24317D06E8,CLSID_WICImagingFactory,0x0)
NumPut("UInt64",0xC2ABD868CE79F7BD,CLSID_WICImagingFactory,0x8)
IID_IClassFactory:=Buffer(0x10)
NumPut("UInt64",0x0000000000000001,IID_IClassFactory,0x0)
NumPut("UInt64",0x46000000000000C0,IID_IClassFactory,0x8)
DllGetClassObject:=DllCall("GetProcAddress","Ptr",hModule,"AStr","DllGetClassObject","Ptr")
DllCall(DllGetClassObject,"Ptr",CLSID_WICImagingFactory,"Ptr",IID_IClassFactory,"Ptr*",&cf:=0)
IID_IWICImagingFactory:=Buffer(0x10)
NumPut("UInt64",0x4314C395EC5EC8A9,IID_IWICImagingFactory,0x0)
NumPut("UInt64",0x70FF35A9D754779C,IID_IWICImagingFactory,0x8)
ComCall(3,cf,"Ptr",0,"Ptr",IID_IWICImagingFactory,"Ptr*",&pFactory:=0) ;pFactory->CreateInstance
ComCall(3,pFactory,"Str",webpPath,"Ptr",0,"Uint",0x80000000,"Int",0,"Ptr*",&pDecoder:=0) ;pFactory->CreateDecoderFromFilename
ComCall(13 ,pDecoder,"Uint",0,"Ptr*",&pFrame:=0) ;pDecoder->GetFrame
ComCall(10,pFactory,"Ptr*",&pConverter:=0) ;pFactory->CreateFormatConverter
GUID_WICPixelFormat32bppBGRA:=Buffer(0x10)
NumPut("UInt64",0x4BFE4E036FDDC324,GUID_WICPixelFormat32bppBGRA,0x0)
NumPut("UInt64",0x0FC98D76773D85B1,GUID_WICPixelFormat32bppBGRA,0x8)
ComCall(8,pConverter,"Ptr",pFrame,"Ptr",GUID_WICPixelFormat32bppBGRA,"Int",0,"Ptr",0,"Double",0.0,"Int",0) ;pConverter->Initialize
; bpp:=32 ;hard-coded, since above is 32bppBGRA
ComCall(3,pConverter,"Uint*",&width:=0,"Uint*",&height:=0) ;pConverter->GetSize
; cbStride := ((width * bpp + 7) // 8 + 3) & ~3 ; Round up to nearest multiple of 4
cbStride := width*4 ; I don't understand this, just multiply it by 4
pData:=Buffer(cbStride * height)
ComCall(7,pConverter,"Ptr",0,"Uint",cbStride,"Uint",cbStride * height,"Ptr",pData) ;pFlipRotator->CopyPixels
HBITMAP := DllCall("gdi32\CreateBitmap","Int",width,"Int",height,"Uint",1,"Uint",32,"Ptr",pData,"Ptr")
return HBITMAP
}
myGui:=Gui()
myGui.AddPicture(,"HBITMAP:" webpToHBITMAP("C:\Users\User\Downloads\img2.webp"))
myGui.Show()
return
f3::Exitapp