Vcl.Markdown.TMDCustomControl.OnUnknownImage
Prototype
property OnUnknownImage: TUnknownImageEvent read FOnUnknownImage write FOnUnknownImage;
Description
Occurs when an image file cannot be loaded because the format of the file is not supported by the Windows Imaging Component (WIC).
aFileName contains the fully qualified path and filename to load. aFileName can be a temporary cached file if the image was downloaded from the Internet. aSize is the optimal image size for rendering, it can be null. aImage is the object to fill with the resulting image. if OnUnknownImage returns an empty image and the control is associated with a TMDStyle, TMDStyle.OnUnknownImage is invoked.
SVG format is not supported by WIC yet. To embed SVG images into your document, add Vcl.Markdown.Skia to the uses clause of the unit and handle OnUnknownImage as follow:
uses Vcl.Graphics, Vcl.Markdown.Image32 {or Vcl.Markdown.Skia};
procedure TForm1.MDStyle1UnknownImage(Sender: TObject; const aFileName: string; aSize: TSize; const aImage: TWICImage);
begin
aImage.LoadFromFile(aControl, aFileName, aSize);
end;
Vcl.Markdown.Skia declares a TWICImage helper, which in turn uses SKIA for SVG image loading.
Notes
- SVG using Skia
- With Delphi XE8 up to 11 you will need to install the Skia4Delphi package first.
- You must distribute the sk4d.dll Skia library with your application regardless of the Delphi version.
- SVG using Image32
- you will need to download and extract the Image32 package. Then to add the Source and Source\Clipper2 folders to the EDI library path or to your project search path.