-
Notifications
You must be signed in to change notification settings - Fork 481
Open
Description
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)
void Main()
{
string template =
"""
<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>
""";
var svgs = new string[] {
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 (var svg in svgs)
{
var svgDoc = SvgDocument.FromSvg<SvgDocument>(svg);
var bitmap = svgDoc.Draw();
bitmap.Dump();
}
}
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
Metadata
Metadata
Assignees
Labels
No labels