Commit 8a982713 authored by tebjan's avatar tebjan
Browse files

added a test image and fixed a bug in rectangle size rendering. fixes #178

parent 60777d50
......@@ -178,7 +178,7 @@ namespace Svg
{
if ((_path == null || IsPathDirty) && base.StrokeWidth > 0)
{
float halfStrokeWidth = base.StrokeWidth / 2;
var halfStrokeWidth = new SvgUnit(base.StrokeWidth / 2);
// If it is to render, don't need to consider stroke
if (renderer != null)
......@@ -193,8 +193,10 @@ namespace Svg
// Starting location which take consideration of stroke width
SvgPoint strokedLocation = new SvgPoint(Location.X - halfStrokeWidth, Location.Y - halfStrokeWidth);
var rectangle = new RectangleF(strokedLocation.ToDeviceValue(renderer, this),
SvgUnit.GetDeviceSize(this.Width + halfStrokeWidth * 2, this.Height + halfStrokeWidth * 2, renderer, this));
var width = this.Width.ToDeviceValue(renderer, UnitRenderingType.Horizontal, this) + base.StrokeWidth;
var height = this.Height.ToDeviceValue(renderer, UnitRenderingType.Vertical, this) + base.StrokeWidth;
var rectangle = new RectangleF(strokedLocation.ToDeviceValue(renderer, this), new SizeF(width, height));
_path = new GraphicsPath();
_path.StartFigure();
......
......@@ -41,6 +41,9 @@
this.picPng = new System.Windows.Forms.PictureBox();
this.label2 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.fIleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.runAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.tableLayoutPanel1.SuspendLayout();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
......@@ -51,6 +54,7 @@
this.tableLayoutPanel3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picSVGPNG)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.picPng)).BeginInit();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
// lstFiles
......@@ -59,7 +63,7 @@
this.lstFiles.FormattingEnabled = true;
this.lstFiles.Location = new System.Drawing.Point(3, 3);
this.lstFiles.Name = "lstFiles";
this.lstFiles.Size = new System.Drawing.Size(174, 768);
this.lstFiles.Size = new System.Drawing.Size(174, 744);
this.lstFiles.TabIndex = 0;
this.lstFiles.SelectedIndexChanged += new System.EventHandler(this.lstFiles_SelectedIndexChanged);
//
......@@ -71,11 +75,11 @@
this.tableLayoutPanel1.Controls.Add(this.splitContainer1, 1, 0);
this.tableLayoutPanel1.Controls.Add(this.lstFiles, 0, 0);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 24);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 1;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(1249, 774);
this.tableLayoutPanel1.Size = new System.Drawing.Size(1249, 750);
this.tableLayoutPanel1.TabIndex = 1;
//
// splitContainer1
......@@ -91,7 +95,7 @@
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.tableLayoutPanel3);
this.splitContainer1.Size = new System.Drawing.Size(1063, 768);
this.splitContainer1.Size = new System.Drawing.Size(1063, 744);
this.splitContainer1.SplitterDistance = 548;
this.splitContainer1.TabIndex = 0;
//
......@@ -111,17 +115,17 @@
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel2.Size = new System.Drawing.Size(548, 768);
this.tableLayoutPanel2.Size = new System.Drawing.Size(548, 744);
this.tableLayoutPanel2.TabIndex = 0;
//
// picSaveLoad
//
this.picSaveLoad.BackColor = System.Drawing.Color.White;
this.picSaveLoad.Dock = System.Windows.Forms.DockStyle.Fill;
this.picSaveLoad.Location = new System.Drawing.Point(0, 397);
this.picSaveLoad.Location = new System.Drawing.Point(0, 385);
this.picSaveLoad.Margin = new System.Windows.Forms.Padding(0);
this.picSaveLoad.Name = "picSaveLoad";
this.picSaveLoad.Size = new System.Drawing.Size(548, 371);
this.picSaveLoad.Size = new System.Drawing.Size(548, 359);
this.picSaveLoad.TabIndex = 2;
this.picSaveLoad.TabStop = false;
//
......@@ -141,14 +145,14 @@
this.picSvg.Location = new System.Drawing.Point(0, 13);
this.picSvg.Margin = new System.Windows.Forms.Padding(0);
this.picSvg.Name = "picSvg";
this.picSvg.Size = new System.Drawing.Size(548, 371);
this.picSvg.Size = new System.Drawing.Size(548, 359);
this.picSvg.TabIndex = 1;
this.picSvg.TabStop = false;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(3, 384);
this.label3.Location = new System.Drawing.Point(3, 372);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(80, 13);
this.label3.TabIndex = 3;
......@@ -170,17 +174,17 @@
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel3.Size = new System.Drawing.Size(511, 768);
this.tableLayoutPanel3.Size = new System.Drawing.Size(511, 744);
this.tableLayoutPanel3.TabIndex = 0;
//
// picSVGPNG
//
this.picSVGPNG.BackColor = System.Drawing.Color.White;
this.picSVGPNG.Dock = System.Windows.Forms.DockStyle.Fill;
this.picSVGPNG.Location = new System.Drawing.Point(0, 397);
this.picSVGPNG.Location = new System.Drawing.Point(0, 385);
this.picSVGPNG.Margin = new System.Windows.Forms.Padding(0);
this.picSVGPNG.Name = "picSVGPNG";
this.picSVGPNG.Size = new System.Drawing.Size(511, 371);
this.picSVGPNG.Size = new System.Drawing.Size(511, 359);
this.picSVGPNG.TabIndex = 3;
this.picSVGPNG.TabStop = false;
//
......@@ -191,7 +195,7 @@
this.picPng.Location = new System.Drawing.Point(0, 13);
this.picPng.Margin = new System.Windows.Forms.Padding(0);
this.picPng.Name = "picPng";
this.picPng.Size = new System.Drawing.Size(511, 371);
this.picPng.Size = new System.Drawing.Size(511, 359);
this.picPng.TabIndex = 2;
this.picPng.TabStop = false;
//
......@@ -200,25 +204,52 @@
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(3, 0);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(68, 13);
this.label2.Size = new System.Drawing.Size(83, 13);
this.label2.TabIndex = 0;
this.label2.Text = "PNG Render";
this.label2.Text = "Reference PNG";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(3, 384);
this.label4.Location = new System.Drawing.Point(3, 372);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(69, 13);
this.label4.TabIndex = 4;
this.label4.Text = "SVG vs PNG";
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fIleToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(1249, 24);
this.menuStrip1.TabIndex = 2;
this.menuStrip1.Text = "menuStrip1";
//
// fIleToolStripMenuItem
//
this.fIleToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.runAllToolStripMenuItem});
this.fIleToolStripMenuItem.Name = "fIleToolStripMenuItem";
this.fIleToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
this.fIleToolStripMenuItem.Text = "File";
//
// runAllToolStripMenuItem
//
this.runAllToolStripMenuItem.Name = "runAllToolStripMenuItem";
this.runAllToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.runAllToolStripMenuItem.Text = "Run All";
this.runAllToolStripMenuItem.Click += new System.EventHandler(this.RunAllToolStripMenuItemClick);
//
// View
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1249, 774);
this.Controls.Add(this.tableLayoutPanel1);
this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1;
this.Name = "View";
this.Text = "Form1";
this.tableLayoutPanel1.ResumeLayout(false);
......@@ -233,7 +264,10 @@
this.tableLayoutPanel3.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.picSVGPNG)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.picPng)).EndInit();
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
......@@ -253,6 +287,9 @@
private System.Windows.Forms.PictureBox picSVGPNG;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem fIleToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem runAllToolStripMenuItem;
}
}
......@@ -102,7 +102,7 @@ namespace SvgW3CTestRunner
//compare svg to png
try
{
picSVGPNG.Image = PixelDiff((Bitmap)picSvg.Image, (Bitmap)picPng.Image);
picSVGPNG.Image = PixelDiff((Bitmap)picPng.Image, (Bitmap)picSvg.Image);
}
catch (Exception ex)
{
......@@ -139,6 +139,17 @@ namespace SvgW3CTestRunner
}
}
return output;
}
void RunAllToolStripMenuItemClick(object sender, EventArgs e)
{
foreach(string fileName in lstFiles.Items)
{
if (fileName.StartsWith("#")) continue;
}
}
......
......@@ -117,4 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="768" height="576"><defs><linearGradient id="g" x1="265.8207" y1="901.5855" x2="877.3936" y2="901.5855" gradientUnits="userSpaceOnUse" gradientTransform="matrix(0.4609,0,0,0.5405,19.4965,-54.1376)"><stop stop-color="#f50c7f" offset="0"/><stop offset="1"/></linearGradient><linearGradient id="h" x1="265.8207" y1="901.5855" x2="877.3936" y2="901.5855" gradientUnits="userSpaceOnUse" gradientTransform="matrix(0.4609,0,0,0.453,19.4965,61.1356)"><stop stop-color="#3b48f6" offset="0"/><stop offset="1"/></linearGradient><rect id="c" y="87.9368" width="61" height="119.7983"/></defs><rect width="100%" height="100%" fill="#393939"/><path stroke="#f3f3f3" stroke-width="2" d="M0,6.5046H768M0,46.7707H768M0,87.0368H768M0,127.3029H768M0,167.569H768M0,207.8351H768M0,248.1012H768M0,288.3673H768M0,328.6334H768M0,368.8995H768M0,409.1656H768M0,449.4317H768M0,489.6978H768M0,529.9639H768M0,570.23H768M21.21,0V576M61.4761,0V576M101.7422,0V576M142.0083,0V576M182.2744,0V576M222.5405,0V576M262.8066,0V576M303.0727,0V576M343.3388,0V576M383.6049,0V576M423.871,0V576M464.1371,0V576M504.4032,0V576M544.6693,0V576M584.9354,0V576M625.2015,0V576M665.4676,0V576M705.7337,0V576M745.9998,0V576"/><rect x="142.0083" y="248.1012" width="483.1932" height="201.3305" fill="#f3f3f3"/><path d="M222.5313,248.1012H544.6563V328.6294H222.5313"/><path d="M375.4446,368.875H390.6946V413.375"/><rect x="383.6049" y="409.1656" width="120.7983" height="79.5322"/><rect x="143.0083" y="409.1656" width="281.8627" height="48.0443" fill="url(#g)"/><rect x="143.0083" y="449.4317" width="281.8627" height="39.2661" fill="url(#h)"/><rect x="464.1371" y="409.1656" width="160.0644" height="79.5322" fill="#2d2d2d"/><rect x="143.0083" y="207.8351" width="121.798" height="80.5322" id="b"/><use xlink:href="#b" x="119.798" fill="#2d2d2d"/><use xlink:href="#b" x="239.596" fill="#7f7f7f"/><use xlink:href="#b" x="360.394" fill="#f3f3f3"/><use xlink:href="#c" x="142.9083" fill="#cdcdcd"/><use xlink:href="#c" x="203.2083" fill="#cbcd00"/><use xlink:href="#c" x="262.8063" fill="#00cece"/><use xlink:href="#c" x="323.2053" fill="#00cd00"/><use xlink:href="#c" x="383.6043" fill="#cf00cd"/><use xlink:href="#c" x="444.0033" fill="#c00"/><use xlink:href="#c" x="563.1013" fill="#000"/><use xlink:href="#c" x="504.0023" fill="#00c"/><path d="M544.6693,409.1656V489.6978" stroke="#7f7f7f"/><rect x="464.1371" y="328.6334" width="160.0644" height="40.2661" fill="#7f7f7f"/><rect x="482.1371" y="328.6334" width="133.5644" height="40.2661" fill="#cc6b00"/><rect x="197.8308" y="328.6334" width="11.2747" height="40.2661" fill="#7f7f7f"/><rect x="215.862" y="328.6334" width="4.9107" height="40.2661" id="d"/><use xlink:href="#d" x="12.5512"/><use xlink:href="#d" x="24.572"/><use xlink:href="#d" x="36.0625"/><use xlink:href="#d" x="48.4369"/><rect x="275.4358" y="328.6089" width="26.3007" height="40.2661" fill="#7f7f7f"/><rect x="304.7807" y="328.6089" width="2.4359" height="40.2661" id="e"/><use xlink:href="#e" x="6.2115"/><use xlink:href="#e" x="12.423"/><use xlink:href="#e" x="18.6346"/><use xlink:href="#e" x="24.8461"/><use xlink:href="#e" x="31.0576"/><use xlink:href="#e" x="37.2691"/><use xlink:href="#e" x="43.4806"/><use xlink:href="#e" x="49.6921"/><use xlink:href="#e" x="55.9037"/><use xlink:href="#e" x="62.1152"/><rect x="369.4829" y="328.6334" width="22.942" height="40.2661" fill="#7f7f7f"/><rect x="394.9368" y="328.6334" width="2.1707" height="40.2661" id="f"/><use xlink:href="#f" x="5.1663"/><use xlink:href="#f" x="10.3327"/><use xlink:href="#f" x="15.499"/><use xlink:href="#f" x="20.6653"/><use xlink:href="#f" x="25.8317"/><use xlink:href="#f" x="30.998"/><use xlink:href="#f" x="36.1643"/><use xlink:href="#f" x="41.3306"/><use xlink:href="#f" x="46.4969"/><use xlink:href="#f" x="51.6633"/><use xlink:href="#f" x="56.8296"/><use xlink:href="#f" x="61.9959"/><use xlink:href="#f" x="67.1622"/><path d="M383.6049,207.8351V368.8995" stroke="#f3f3f3" stroke-width="2"/><path d="M142.0083,288.3673H625.2015" stroke="#f3f3f3" stroke-width="2"/><circle cx="50%" cy="50%" r="275.5" fill="none" stroke="#f3f3f3" stroke-width="2"/></svg>
\ No newline at end of file
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