Background color for Image generated from StreamSVGConverter

Topics: Converters and Runtime, Styling, SVG, SVG# and Parsing, WPF and GDI+ Renderers
Sep 26, 2016 at 1:55 PM
Is there any setting that I can provide to set the image background color to white while converting SVG to Image Stream? The crystal reports doesn't support the transparent background and displays the image in black color.

Thanks.
Coordinator
Sep 26, 2016 at 4:04 PM
Hello,

Which output are you using from the converter? For image output, the default is PNG, which has by default transparent background but you can set the format you want including bitmap.

Best regards,
Paul.

Sep 26, 2016 at 5:17 PM
Edited Sep 26, 2016 at 5:18 PM
Hi Paul,

Thank you very much for your response.

I'm trying to get Memory Stream output for the image file generated. For your reference, I've given below the code that I'm using:
            Dim svgSettings As New SharpVectors.Renderers.Wpf.WpfDrawingSettings
            Using svg As New SharpVectors.Converters.StreamSvgConverter(svgSettings)
                Using svgMS As New IO.MemoryStream(Encoding.ASCII.GetBytes(svgString))
                    Using imgMS As New IO.MemoryStream()
                        svg.Convert(svgMS, imgMS)
                        bytes = imgMS.ToArray()
                    End Using
                End Using
            End Using
For the Stream Converters, how can I change the image type from PNG (default) to JPEG and the background color to White?

Thanks,
Ranga
Coordinator
Sep 26, 2016 at 10:02 PM
Try setting the EncoderType property to JPEG as in

svg.EncoderType = ImageEncoderType.JpegBitmap

I think the background will be white, if not let me know.

Paul.

Sep 27, 2016 at 3:19 PM
Hey Paul,

I am working with Ranga on this issue. We tried what you said above, but it returns a black background. Any advice?
  • Jason
Coordinator
Sep 29, 2016 at 3:52 AM

Hello Jason,

Sorry for the delay. I will try it this weekend. I'll need to create a sample that demonstrates the problem, then try to look at the possible solutions.

Paul.


Sep 29, 2016 at 1:01 PM
Thanks Paul!
Coordinator
Oct 17, 2016 at 6:05 PM
Hello Jason and Ranga,

I have just updated the sources, adding a new property to the converter, SvgConverter.Background, to address this issue.

The Changeset is 38315, or here https://sharpvectors.codeplex.com/SourceControl/changeset/38315

Best regards,
Paul.
Marked as answer by SelormeyPaul on 10/17/2016 at 11:17 AM
Oct 20, 2016 at 7:15 PM
Thank you very much for the support and the guidance!