Load WEBP image file to FireMonkey TImage

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

begin
Image1.Bitmap.LoadFromFile (vImageFileName);
end;

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.

1 Like

Not sure this works with Firemonkey but might be worth a look

1 Like

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

source code
https://github.com/skia4delphi/skia4delphi

Home
https://skia4delphi.org/

Architecture
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

Instructions

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
	
	   begin
	     Image1.picture.LoadFromFile ('c:\temp\MyWebpImage.webp');
	   end;
	
	
	* You can save WEBP images from a TImage to a file
	
	   begin
	     Image1.picture.SaveToFile ('c:\temp\MyWebpImage.webp');
	   end;
1 Like