Open hjqcan opened 4 years ago
Description Convert svg to png wrong size.Origin svg size 432.After converted,it had been changed to 3xx
Following is the code I used:
var svgDoc = SvgDocument.Open("c:\a.svg"); Bitmap bitmap= svgDoc.Draw(); bitmap.Save("c:\a.png",ImageFormat.Png);
Example data
SVG data:
<?xml version="1.0" encoding="UTF-8"?> <svg enable-background="new 0 0 432 432" version="1.1" viewBox="0 0 432 432" xmlns="http://www.w3.org/2000/svg"> <style type="text/css">.st0{fill:#C87B33;} .st1{fill:#DA1C5C;} .st2{fill:#414042;} .st3{fill:#98B4C0;} .st4{fill:#CB7B29;} .st5{fill:#D97986;}</style> <path class="st1" d="m204.3 356.4c0.4-0.6 0.8-1 1.1-1.5 10-15.8 22-30.1 35-43.6 11.8-12.3 24-24.1 36-36.1 14-13.9 27.6-28 39.8-43.5 11.2-14 21.4-28.7 29.5-44.7 6.6-13 11.4-26.6 13.5-41.1 2-13.7 1.2-27.3-3.8-40.4-6.9-18.2-20.2-29.4-38.9-34.2-18.4-4.7-34.8-0.5-49 12-6.8 6-12.7 13-18.1 20.3-8.9 12.2-17.8 24.5-25.3 37.7-1.5 2.6-4.8 3.7-7.6 2.6-1.6-0.6-2.2-1.6-1.7-3.3 0.3-1.2 0.7-2.4 1.3-3.5 8.6-15.9 17.2-31.8 29.2-45.5 3.3-3.7 6.7-7.2 10.4-10.4 10.7-9.3 23.1-14.6 37.2-16.2 13.3-1.5 26.1 0.2 38.3 5.6 19.6 8.6 31.4 23.6 35.6 44.5 3.1 15.5 1.4 30.7-3.2 45.6-5.4 17.5-13.8 33.5-24 48.6-12.1 17.8-26 34.2-41 49.6-13.8 14.1-27.7 28.1-41.5 42.3-11.6 11.9-22.7 24.1-32.6 37.5-5.6 7.6-10.7 15.5-14.5 24.2-1.1 2.4-2.8 3.6-5.3 3.9-3.9 0.5-7.3-0.3-9.6-3.8-0.9-1.3-1.8-2.6-2.6-4-9.7-17.3-21.5-33.1-33.5-48.8-16.3-21.2-33.3-41.8-50.4-62.4-10-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6-1-3.9-1.5-7.8-1.3-11.9 0.2-3.9 1.2-7.6 3.1-11 2.7-4.9 9-5.9 13.2-2.2 1.9 1.7 3.3 3.7 4.5 5.9 5.5 10.1 9.2 20.8 11.1 32.2 0.6 3.9 1 7.8 1.1 11.7 0 1.3-0.2 1.9 0.4 2.5zm-21.2-46.4c-0.7 1.7-0.6 3.2-0.5 4.8 0.4 4.6 1.6 9 3.2 13.3 2.7 7.3 5.5 14.4 9.6 21.1 0.7 1.1 1.3 2.2 2.8 3.5-0.8-16.2-6.1-30.1-15.1-42.7z"/> <path d="m228.7 161.9c1.2 0 2.3-0.1 3.4 0.3 2.8 0.8 4.4 2.8 4.4 5.6 0.1 2.9-1.3 4.8-4 5.9-2.4 0.9-4.7 0.9-7-0.1-2.8-1.1-4.4-3.8-3.9-6.7 0.5-3 2.5-4.7 5.6-4.9 0.5-0.2 1-0.1 1.5-0.1z"/> </svg>
@hjqcan
I got the correct png. (Windows 10, .NET Framework 4.6.1 and .Net 5)
Description Convert svg to png wrong size.Origin svg size 432.After converted,it had been changed to 3xx
Following is the code I used:
var svgDoc = SvgDocument.Open("c:\a.svg");
Bitmap bitmap= svgDoc.Draw();
bitmap.Save("c:\a.png",ImageFormat.Png);
Example data
SVG data: