iseahound / ImagePut

A core library for images in AutoHotkey. Supports AutoHotkey v1 and v2.
https://www.autohotkey.com/boards/viewtopic.php?f=83&t=76633
MIT License
116 stars 24 forks source link

ImagePutWindow fails on webp #49

Closed cnieuweboer closed 1 month ago

cnieuweboer commented 1 month ago

I am using the ahk v1 version, and use the imageputwindow function as follows imagewindow_handle := ImagePutWindow(imagefile,"image window",coordinates,0x80000000,0x08000028)

When I use a webp file it gives me an error. image

Gif files work fine.

Example animated webp file https://www.tutorialexample.com/wp-content/uploads/2020/09/gif-test-2.webp

Example animated giffile https://www.tutorialexample.com/wp-content/uploads/2020/09/gif-test.gif

The supported formats website says animated webp should work. https://github.com/iseahound/ImagePut/wiki/Quick-Start#accepts

iseahound commented 1 month ago

Have you tried downloading the latest version here?

https://github.com/iseahound/ImagePut/blob/master/ImagePut%20(for%20v1).ahk

cnieuweboer commented 1 month ago

Yes that is the version I am using.

cnieuweboer commented 1 month ago

I am also using the Gdip standard library v1.45 somewhere else in the script, for other purposes. It seems pToken := Gdip_StartUp() causes webp to fail. Without pToken := Gdip_StartUp() the webp image does load, but doesn't animate.

iseahound commented 1 month ago

Looks like the image file isn't being parsed correctly. I'll take a deeper look at the sample image you provided, I manually added code to parse WebP frames.

ImagePutWindow("https://mathiasbynens.be/demo/animated-webp-supported.webp")

Most other webp animations work :)

iseahound commented 1 month ago

For your pToken startup problem, you can use ImagePut's loader: ImagePut.gdiplusStartup()

cnieuweboer commented 1 month ago

Thanks, that works. Guess I should just use the library as it was intended then.

iseahound commented 1 month ago

I still couldn't get your animated webp to correctly animate in ImagePutWindow however.

iseahound commented 1 month ago

Partially fixed by b5242ba7e4c1cbd653b3c687788a83d6a04d0e6c.

Your sample image has frame delays of 0, which I've now set to 100ms as per chrome / firefox.

cnieuweboer commented 1 month ago

Can confirm that fixes the animation. But it stops after 1 cycle, other webp/gif files repeat the animation.

iseahound commented 1 month ago

Fully fixed by f6788aa953f9b61c11b4738206d9661518fc71ee

iseahound commented 1 month ago

Also feel free to play with this example here: https://github.com/iseahound/ImagePut/wiki/Add-Image-to-AutoHotkey-GUI#bonus-synchronize-animations which includes some useful animation functions.