softtouch 9 Posted July 4, 2022 I need to convert some webp images to jpg or any other format (target format does not matter). How can I load a .webp image into a timage without using any external dll/dylib like Skia4Delphi? I just cant find anything realted to .webp and fmx. Share this post Link to post
Alexander Halser 26 Posted November 10, 2023 I just realized, more or less by accident, that an FMX TBitmap can load WebP image files. I tested a few of them, but they seem to be all perfectly fine. bmp := TBitmap.create; bmp.LoadFromFile('C:\Users\Alexander\Pictures\_test.webp'); bmp.SaveToFile('C:\Users\Alexander\Pictures\_test.png'); //works bmp.SaveToFile('C:\Users\Alexander\Pictures\_test.webp'); //this fails! The load dialog in the IDE does not include webp, so you cannot select it. You can rename a webp image to ".bmp" and load it though. Internally, the TFixedMultiResBitmap converts it to PNG data, which heavily increases the binary image data stored in the form. It's like you had used a PNG in the first place. So, when using webP for UI display, it probably makes sense to store them as RC_DATA resources and load from a resource stream at runtime. Saving WebP fails with an error. The webp feature seems to come from the operating system. GDI+ explicitly mentions WEBP among other formats: Image File Format Constants (Gdiplusimaging.h) - Win32 apps | Microsoft Learn Does anyone know since when GDI+ supports WebP? Was this implemented in Windows 8 or Windows 10? I am pretty sure that Windows 7 GDI+ did not support it. Which means that an FMX app that runs on Win7 would not be able to load it at runtime. Share this post Link to post
Alexander Sviridenkov 360 Posted November 10, 2023 Maybe this come from SKIA webp support? Share this post Link to post
Alexander Halser 26 Posted November 10, 2023 1 hour ago, Alexander Sviridenkov said: Maybe this come from SKIA webp support? Nope. Delphi 11.3 without Skia, just FMX with GDI+. WebP works on MacOS as well, probably iOS, too. Share this post Link to post
vfbb 285 Posted November 10, 2023 16 minutes ago, Alexander Halser said: Delphi 11.3 without Skia, just FMX with GDI+. Maybe you have the "Webp Image Extensions" installed: https://apps.microsoft.com/detail/9PG2DK419DRG Share this post Link to post
Alexander Halser 26 Posted November 10, 2023 5 hours ago, vfbb said: Maybe you have the "Webp Image Extensions" installed Not that I know of, but MS Edge keeps installing new stuff on it's own... Share this post Link to post