You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a CSS color is specified using a hex string that includes the alpha channel, the resulting color is black regardless of value. Specifying the alpha channel another way (e.g.: via rgb()) seems to work as expected though.
Example data
Reproduction example. (via LINQPad)
voidMain(){stringtemplate="""<svg viewBox="0 0 192 64" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <style type="text/css"> text {{ fill: {0}; }} rect {{ fill: #ffffff; }} </style> <rect width="100%" height="100%" /> <text x="32" y="32" class="name">{1}</text></svg>""";varsvgs=newstring[]{string.Format(template,"rgb(255, 0, 0, 255)","Rgb red w/ alpha"),string.Format(template,"rgb(255, 0, 0, 128)","Rgb red w/ alpha 128"),string.Format(template,"rgb(255, 0, 0)","Rgb red w/ *no* alpha"),string.Format(template,"#ff0000ff","Hex red w/ alpha 0xFF"),string.Format(template,"#ff000080","Hex red w/ alpha 0x80"),string.Format(template,"#ff0000","Hex red w/ *no* alpha"),};foreach(varsvginsvgs){varsvgDoc=SvgDocument.FromSvg<SvgDocument>(svg);varbitmap=svgDoc.Draw();bitmap.Dump();}}
Output result:
Used Versions
Svg v3.4.4 (Nuget)
.NET v7.0.5 (Roslyn v4.6.0-3.23259.8)
OS Windows 10 Pro For Workstations 22H2 19045.3086
The text was updated successfully, but these errors were encountered:
Description
If a CSS color is specified using a hex string that includes the alpha channel, the resulting color is black regardless of value. Specifying the alpha channel another way (e.g.: via
rgb()
) seems to work as expected though.Example data
Reproduction example. (via LINQPad)
Output result:
Used Versions
Svg v3.4.4 (Nuget)
.NET v7.0.5 (Roslyn v4.6.0-3.23259.8)
OS Windows 10 Pro For Workstations 22H2 19045.3086
The text was updated successfully, but these errors were encountered: