How can I load a WEBP image to a FireMonkey TImage
This code works for BMP, PNG, GIF and JPG but does not work for WEBP
If that is not possible, please provide code to convert a WEBP image file to BMP, PNG, GIF or JPEG
Environment - Delphi XE 8. I prefer not to upgrade this application, but might have to if it is required to get WEBP support.
I haven’t used it myself, but it appears Skia4Delphi adds support for WEBP. It looks like it is mostly fmx, but I think the file formats support VCL as well.
Not sure this works with Firemonkey but might be worth a look
I was also looking to convert webp images to bmp.
Skia4Delphi looks like it might do it when I convert the project to 11.3 but was hoping for something I can use with XE in the meantime.
Scott, did you end up moving forward with anything?
I’m trying to work out how to use libwebp.dll to load a webp file into a TBitmap, but am stuck at present as the examples use TGPBitmap.
@David_Duffy sorry I only just saw your reply
Yes I managed to get Skia working to load WEBP images into a VCL TImage and I expect it works for FireMonkey. The Skia installer did not work for XE8 on an old version of Windows 10, but is supposed to work for more up to date versions
Here are some notes that I provided to the Perth branch about this
WEBP image support can be added to Delphi using part of the (FREE) Skia4Delphi add-on
This worked ok for VCL.
I did not test Firemonkey.
It might require some minor changes.
The GitHub page mentioned FMX so it should be ok
Carefully follow the instructions on the GitHub page
which should be this :
- Download and install Skia either from GitHub (see above)
or from https://skia4delphi.org/ >>> click DOWNLOAD LATEST VERSION
- Start Delphi and open a Delphi project
then Right click on the project (Project1.exe) and click **"Enable Skia"** from the popup menu
- include the DLL (sk4d.sqll) in the same folder as your *.EXE file.
Also copy the DLL to the DEBUG and RELEASE folder for your project
so it can be accessed when running your program from then Delphi.
There might be a way to specify the folder that the DLL is in,
but I have not looked in to that
- Include these two units in your USES clause.
* USES Skia, Skia.Vcl; // required for WEBP image support
- You now have native WEBP support in Delphi (only for the project that you did "Enable Skia" in (see above).
Delphi will know that an image is a WEBP based on the file extension (*.webp)
- load and save WEBP image
* You can load WEBP images into a TImage from a file
* You can save WEBP images from a TImage to a file