Commit 4439d56a authored by H1Gdev's avatar H1Gdev Committed by mrbean-bremen
Browse files

Fix: preserveAspectRatio attribute default value is wrong.

In <image> element, preserveAspectRatio attribute default value is 'xMidYMid meet'.

https://www.w3.org/TR/SVG11/coords.html#PreserveAspectRatioAttribute
parent aa1aa3f5
...@@ -151,14 +151,15 @@ namespace Svg ...@@ -151,14 +151,15 @@ namespace Svg
renderer.SetClip(new Region(destClip), CombineMode.Intersect); renderer.SetClip(new Region(destClip), CombineMode.Intersect);
this.SetClip(renderer); this.SetClip(renderer);
if (AspectRatio != null && AspectRatio.Align != SvgPreserveAspectRatio.none) SvgAspectRatio aspectRatio = AspectRatio ?? new SvgAspectRatio(SvgPreserveAspectRatio.xMidYMid);
if (aspectRatio.Align != SvgPreserveAspectRatio.none)
{ {
var fScaleX = destClip.Width / srcRect.Width; var fScaleX = destClip.Width / srcRect.Width;
var fScaleY = destClip.Height / srcRect.Height; var fScaleY = destClip.Height / srcRect.Height;
var xOffset = 0.0f; var xOffset = 0.0f;
var yOffset = 0.0f; var yOffset = 0.0f;
if (AspectRatio.Slice) if (aspectRatio.Slice)
{ {
fScaleX = Math.Max(fScaleX, fScaleY); fScaleX = Math.Max(fScaleX, fScaleY);
fScaleY = Math.Max(fScaleX, fScaleY); fScaleY = Math.Max(fScaleX, fScaleY);
...@@ -169,7 +170,7 @@ namespace Svg ...@@ -169,7 +170,7 @@ namespace Svg
fScaleY = Math.Min(fScaleX, fScaleY); fScaleY = Math.Min(fScaleX, fScaleY);
} }
switch (AspectRatio.Align) switch (aspectRatio.Align)
{ {
case SvgPreserveAspectRatio.xMinYMin: case SvgPreserveAspectRatio.xMinYMin:
break; break;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment