I have an svg. I want to create a png with c#.
It works fine but the only problem is transparency. The created png has always a white background.
If I open the original svg on a browser or in inkescape i see a transparent background.
Don't know if i must explicit transparency on svg source(in a specific way) or if i must use a particolar option in Magick.net library.
Thanks in advance for any tip.
This is my function:
It works fine but the only problem is transparency. The created png has always a white background.
If I open the original svg on a browser or in inkescape i see a transparent background.
Don't know if i must explicit transparency on svg source(in a specific way) or if i must use a particolar option in Magick.net library.
Thanks in advance for any tip.
This is my function:
private Stream convertSVG(Stream svgAsStream)
{
Stream convertedImage = new MemoryStream();
using (MagickImage MGKimage = new MagickImage())
{
//MGKimage.ColorAlpha(new MagickColor(255, 255, 255)); //alpha on white
//MGKimage.Alpha(AlphaOption.Background);
//set input image proprieties: SVG
MagickReadSettings mrs = new MagickReadSettings();
mrs.Format = MagickFormat.Svg;
mrs.ColorSpace = ColorSpace.Transparent;
MGKimage.Read(svgAsStream, mrs);
//set output image proprieties: PNG
MGKimage.Format = MagickFormat.Png;
MGKimage.BackgroundColor = new MagickColor(System.Drawing.Color.Transparent);
MGKimage.Write(convertedImage);
}
return convertedImage;
}