Three engines to render SVG (Delphi Image32, Skia4Delphi, Direct2D wrapper) and four components to simplify use of SVG images (resize, fixedcolor, grayscale...)
Apache License 2.0
321
stars
93
forks
source link
D2D factory fills elements with fill="none" with FixedColor. #166
and in D2DSVGFactory.pas replace RecolorSubtreewith:
procedure RecolorSubtree(const Element: ID2D1SvgElement; NewColor: TD2D1ColorF);
begin
TransformSvgElement(Element,
procedure(const Element: ID2D1SvgElement)
procedure RecolorAttribute(Attr: PWideChar);
var
IsInherited: Bool;
TextValue: string;
Count: UINT32;
begin
if Element.IsAttributeSpecified(Attr, @IsInherited) and not IsInherited then
begin
if not Succeeded(Element.GetAttributeValueLength(Attr, D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, Count)) then Exit;
SetLength(TextValue, Count);
if not Succeeded(Element.GetAttributeValue(Attr, D2D1_SVG_ATTRIBUTE_STRING_TYPE_SVG, PWideChar(TextValue), Count+1)) then Exit;
if TextValue = 'none' then
Exit;
Element.SetAttributeValue(Attr, D2D1_SVG_ATTRIBUTE_POD_TYPE_COLOR,
@NewColor, SizeOf(NewColor));
end;
end;
begin
RecolorAttribute('fill');
RecolorAttribute('stroke');
RecolorAttribute('stop-color');
end);
end;
Here are a couple of fixes for the D2D factory:
In D2DMissing.pas the GetAttribute overload at line 3010 should be:
and in D2DSVGFactory.pas replace RecolorSubtreewith: