Sorry for the bad english (in the USSR there was no foreign languages).
I have troubles with embedded images.
Option A:
.svg file with embedded image (created from Corel Draw 13).
The image is transformed by scaling and offset.
image is placed into the clip
In this case, scaling applied 1) on our image, and then 2) offset of the clip. Although scaling should not be applied to offset.
Option B:
.svg file with embedded image (created from Corel Draw 18).
Here we have wrong scaling because of default scale for image == SvgPreserveAspectRatioType.XMidYMid
So I made some minor changes in WpfImageRendering.cs, project SharpVectors.Rendering.Wpf:
1) for Option A: added correction of the offset (line 461, function GetAspectRatioTransform)
if (this.Transform != null)
{
if (scaleX != 1.0f && this.Transform.Value.OffsetX != 0.0)
translateX = translateX + this.Transform.Value.OffsetX (1 - scaleX);
if (scaleY != 1.0f && this.Transform.Value.OffsetY != 0.0)
translateY = translateY + this.Transform.Value.OffsetY (1 - scaleY);
}
2) for Option B: check for default scaling (line 130, function Render)
old version:
destRect = this.GetBounds(destRect,
new Size(imageWidth, imageHeight), aspectRatioType);
new version:
if (!aspectRatio.IsDefaultAlign)
destRect = this.GetBounds(destRect, new Size(imageWidth, imageHeight), aspectRatioType);
3) Correct minor bag (line 463, function GetAspectRatioTransform). I was not able to test this, but it should be logically.
old version:
if ((float)translateX >= 0 && (float)translateY >= 0)
new version:
if ((float)translateX >= 0 || (float)translateY >= 0)
4) Correct minor bag (line 467, function GetAspectRatioTransform). I was not able to test this, but it should be logically
old version:
if ((float)scaleX != 1.0f && (float)scaleY != 1.0)
new version:
if ((float)scaleX != 1.0f || (float)scaleY != 1.0)
.svg-samples and corrected WpfImageRendering.cs file (all my changes I mark as //Cacxa) you can find here: https://yadi.sk/d/jG_aF-mOxerkG
Hi all,
Sorry for the bad english (in the USSR there was no foreign languages).
I have troubles with embedded images.
Option A: .svg file with embedded image (created from Corel Draw 13). The image is transformed by scaling and offset.
image is placed into the clip
In this case, scaling applied 1) on our image, and then 2) offset of the clip. Although scaling should not be applied to offset.
Option B: .svg file with embedded image (created from Corel Draw 18). Here we have wrong scaling because of default scale for image == SvgPreserveAspectRatioType.XMidYMid
So I made some minor changes in WpfImageRendering.cs, project SharpVectors.Rendering.Wpf: 1) for Option A: added correction of the offset (line 461, function GetAspectRatioTransform) if (this.Transform != null) { if (scaleX != 1.0f && this.Transform.Value.OffsetX != 0.0) translateX = translateX + this.Transform.Value.OffsetX (1 - scaleX); if (scaleY != 1.0f && this.Transform.Value.OffsetY != 0.0) translateY = translateY + this.Transform.Value.OffsetY (1 - scaleY); }
2) for Option B: check for default scaling (line 130, function Render) old version: destRect = this.GetBounds(destRect, new Size(imageWidth, imageHeight), aspectRatioType);
new version: if (!aspectRatio.IsDefaultAlign) destRect = this.GetBounds(destRect, new Size(imageWidth, imageHeight), aspectRatioType);
3) Correct minor bag (line 463, function GetAspectRatioTransform). I was not able to test this, but it should be logically. old version: if ((float)translateX >= 0 && (float)translateY >= 0)
new version: if ((float)translateX >= 0 || (float)translateY >= 0)
4) Correct minor bag (line 467, function GetAspectRatioTransform). I was not able to test this, but it should be logically old version: if ((float)scaleX != 1.0f && (float)scaleY != 1.0)
new version: if ((float)scaleX != 1.0f || (float)scaleY != 1.0)
.svg-samples and corrected WpfImageRendering.cs file (all my changes I mark as //Cacxa) you can find here: https://yadi.sk/d/jG_aF-mOxerkG
Attachments
SVG.zip
This work item was migrated from CodePlex
CodePlex work item ID: '2017' Assigned to: 'SelormeyPaul' Vote count: '2'