EtheaDev / SVGIconImageList

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

Fixed color should not be applied to fill='url()' #171

Closed pyscripter closed 3 years ago

pyscripter commented 3 years ago

As per title. This is not an issue with the Pascal SVG. The fix for the D2D Factory is to change the RecolorAttribute to

procedure RecolorAttribute(const Element: ID2D1SvgElement; Attr: PWideChar; NewColor: TD2D1ColorF);
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') or TextValue.StartsWith('url') then
      Exit;
    Element.SetAttributeValue(Attr, D2D1_SVG_ATTRIBUTE_POD_TYPE_COLOR,
        @NewColor, SizeOf(NewColor));
  end;
end;

Just one line was changed ( TextValue.StartsWith('url'))

@carloBarazzetta Could you please make the change?