I use Skia4Delphi in my VCL application. I have an Image1 (TImage) component. It supports loading webp image files thanks to Skia4Delphi. However I get "Cannot assign a TSkGraphic to a TBitmap" error when I try to convert a webp image to TBitmap. No error message for PNG or JPEG files.
Here is an example code:
uses System.Skia, VCL.Skia;
var
Bitmap: TBitmap;
begin
Image1.Picture.LoadFromFile('c:\image.webp'); // No error
Bitmap := TBitmap.Create;
try
Bitmap.Assign(Image1.Picture.Graphic); // Error for webp files
finally
Bitmap.Free;
end;
end;
How to fix the error and load the webp image into TBitmap?
The suggestion Robert wrote as a comment works.