SVG
SVG copied to clipboard
SvgDocument Background color not rendered properly
Expected:
Background color renders White (#FFFFFF
) as per the SVG specifications.
When an SVG document is a top-level document, meaning it is not embedded in another document, the root ‘svg’ element is considered to be the page group and is composited with a backdrop of white with 100% opacity. From https://www.w3.org/TR/SVG2/render.html#ParentCompositing
Actual:
Background renders transparent.
I have tried several attempts to get a white background. Is there something I am missing from the API? Here is my current solution that gets me the white background as I expect, however, this feels like it should be part of the Draw method to comply with the SVG spec.
var bitmap = new Bitmap(
(int)self.ViewBox.Width,
(int)self.ViewBox.Height,
PixelFormat.Format32bppArgb);
using (var g = Graphics.FromImage(bitmap))
{
g.FillRegion(Brushes.White, new Region(new Rectangle(0, 0, bitmap.Width, bitmap.Height)));
}
self.Draw(bitmap);
return bitmap;
Is there a description in SVG1.1 about background color ?