Convert a MemoryStream of a SVG string to a PNG image

Oct 23, 2014 at 4:09 PM
I'm confused on how the memorystream interacts with the Magic.NET library. I'm not sure if this library supports reading a string and converting it to an image so I decided to create my SVG string into a stream in order to try and interact with Magick.NET stream library. I have not been able to figure out how to either convert my SVG string to an image or how to convert my SVG string stream to an image.

Any help would be great

Thanks
Coordinator
Oct 23, 2014 at 10:17 PM
It does support reading it but you need to tell Magick.NET the type of image you are reading. Here is an example of how you could do that:
byte[] bytes = Encoding.UTF8.GetBytes(svgStr);

MagickReadSettings settings = new MagickReadSettings()
{
  Format = MagickFormat.Svg
};

using (MagickImage image = new MagickImage(bytes,settings))
{
  image.Write(@"C:\Snakeware.png");
}
Oct 24, 2014 at 5:03 PM
thanks!