@@ -25,15 +25,12 @@ protected override Document GetFlatDocument(string svgdata, SvgImportConfig conf
2525 using BenchmarkScope _ = new BenchmarkScope ( ) ;
2626 using MemoryFailPoint mfp = GetMemoryFailPoint ( width , height , 1 ) ;
2727 ResetProgress ( 1 ) ;
28- Surface surface = new Surface ( width , height , SurfaceCreationFlags . DoNotZeroFillHint ) ;
28+ Surface surface = new Surface ( width , height ) ;
2929 try
3030 {
31- using ( Resvg resvg = Resvg . FromData ( svgdata , loadSystemFonts : true ) )
32- {
33- ResvgTransform transform = CalculateTransform ( resvg . Size , config ) ;
34- resvg . Render ( surface . Scan0 . Pointer , transform , width , height ) ;
35- }
36- surface . ConvertFromPrgba ( ) ;
31+ using Resvg resvg = Resvg . FromData ( svgdata , loadSystemFonts : true ) ;
32+ ResvgTransform transform = CalculateTransform ( resvg . Size , config ) ;
33+ resvg . Render ( surface . Scan0 . Pointer , transform , width , height , PixelOpFlags . RgbaToBgra | PixelOpFlags . UnPremultiplyAlpha ) ;
3734 }
3835 catch ( Exception )
3936 {
@@ -66,7 +63,7 @@ protected override Document GetLayeredDocument(string svgdata, SvgImportConfig c
6663 using ResvgOptions options = new ResvgOptions ( ) ;
6764 options . LoadSystemFonts ( ) ;
6865
69- using Surface surface = new Surface ( config . RasterWidth , config . RasterHeight ) ;
66+ using Surface surface = new Surface ( config . RasterWidth , config . RasterHeight , SurfaceCreationFlags . DoNotZeroFillHint ) ;
7067 // Render all visual elements that are passed here.
7168 foreach ( SvgVisualElement element in elements )
7269 {
@@ -141,9 +138,9 @@ private void RenderSvgDocument(SvgElement element, Surface surface, ResvgOptions
141138 else
142139 {
143140 SvgDocument clone = element . OwnerDocument . RemoveInvisibleAndNonTextElements ( ) ;
144- using ( Resvg resvg = Resvg . FromData ( clone . GetXML_QuotedFuncIRIHack ( ) , options ) )
145- resvg . Render ( surface . Scan0 . Pointer , surface . Width , surface . Height ) ;
146- surface . ConvertFromPrgba ( ) ;
141+ ( int width , int height ) = ( surface . Width , surface . Height ) ;
142+ using Resvg resvg = Resvg . FromData ( clone . GetXML_QuotedFuncIRIHack ( ) , options ) ;
143+ resvg . Render ( surface . Scan0 . Pointer , width , height , PixelOpFlags . RgbaToBgra | PixelOpFlags . UnPremultiplyAlpha ) ;
147144 }
148145 }
149146
@@ -156,8 +153,8 @@ private static ResvgTransform CalculateTransform(SizeF svgsize, SvgImportConfig
156153 : config . RasterHeight / svgsize . Height * tolerance ;
157154 return new ResvgTransform ( )
158155 {
159- a = ratioX ,
160- d = ratioY
156+ M11 = ratioX ,
157+ M22 = ratioY
161158 } ;
162159 }
163160}
0 commit comments