Commit b86dfd73 authored by tebjan's avatar tebjan
Browse files

improved w3c tester, shows image difference of svg and png now, separate try/catch blocks

parent 16f03c34
......@@ -32,7 +32,7 @@
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
this.picLoadSave = new System.Windows.Forms.PictureBox();
this.picSaveLoad = new System.Windows.Forms.PictureBox();
this.label1 = new System.Windows.Forms.Label();
this.picSvg = new System.Windows.Forms.PictureBox();
this.label3 = new System.Windows.Forms.Label();
......@@ -46,7 +46,7 @@
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.tableLayoutPanel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picLoadSave)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.picSaveLoad)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.picSvg)).BeginInit();
this.tableLayoutPanel3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picSVGPNG)).BeginInit();
......@@ -59,7 +59,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, 670);
this.lstFiles.Size = new System.Drawing.Size(174, 768);
this.lstFiles.TabIndex = 0;
this.lstFiles.SelectedIndexChanged += new System.EventHandler(this.lstFiles_SelectedIndexChanged);
//
......@@ -75,7 +75,7 @@
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(1235, 676);
this.tableLayoutPanel1.Size = new System.Drawing.Size(1249, 774);
this.tableLayoutPanel1.TabIndex = 1;
//
// splitContainer1
......@@ -91,15 +91,15 @@
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.tableLayoutPanel3);
this.splitContainer1.Size = new System.Drawing.Size(1049, 670);
this.splitContainer1.SplitterDistance = 541;
this.splitContainer1.Size = new System.Drawing.Size(1063, 768);
this.splitContainer1.SplitterDistance = 548;
this.splitContainer1.TabIndex = 0;
//
// tableLayoutPanel2
//
this.tableLayoutPanel2.ColumnCount = 1;
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel2.Controls.Add(this.picLoadSave, 0, 3);
this.tableLayoutPanel2.Controls.Add(this.picSaveLoad, 0, 3);
this.tableLayoutPanel2.Controls.Add(this.label1, 0, 0);
this.tableLayoutPanel2.Controls.Add(this.picSvg, 0, 1);
this.tableLayoutPanel2.Controls.Add(this.label3, 0, 2);
......@@ -111,19 +111,19 @@
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(541, 670);
this.tableLayoutPanel2.Size = new System.Drawing.Size(548, 768);
this.tableLayoutPanel2.TabIndex = 0;
//
// picLoadSave
// picSaveLoad
//
this.picLoadSave.BackColor = System.Drawing.Color.White;
this.picLoadSave.Dock = System.Windows.Forms.DockStyle.Fill;
this.picLoadSave.Location = new System.Drawing.Point(0, 348);
this.picLoadSave.Margin = new System.Windows.Forms.Padding(0);
this.picLoadSave.Name = "picLoadSave";
this.picLoadSave.Size = new System.Drawing.Size(541, 322);
this.picLoadSave.TabIndex = 2;
this.picLoadSave.TabStop = false;
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.Margin = new System.Windows.Forms.Padding(0);
this.picSaveLoad.Name = "picSaveLoad";
this.picSaveLoad.Size = new System.Drawing.Size(548, 371);
this.picSaveLoad.TabIndex = 2;
this.picSaveLoad.TabStop = false;
//
// label1
//
......@@ -141,14 +141,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(541, 322);
this.picSvg.Size = new System.Drawing.Size(548, 371);
this.picSvg.TabIndex = 1;
this.picSvg.TabStop = false;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(3, 335);
this.label3.Location = new System.Drawing.Point(3, 384);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(80, 13);
this.label3.TabIndex = 3;
......@@ -170,17 +170,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(504, 670);
this.tableLayoutPanel3.Size = new System.Drawing.Size(511, 768);
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, 348);
this.picSVGPNG.Location = new System.Drawing.Point(0, 397);
this.picSVGPNG.Margin = new System.Windows.Forms.Padding(0);
this.picSVGPNG.Name = "picSVGPNG";
this.picSVGPNG.Size = new System.Drawing.Size(504, 322);
this.picSVGPNG.Size = new System.Drawing.Size(511, 371);
this.picSVGPNG.TabIndex = 3;
this.picSVGPNG.TabStop = false;
//
......@@ -191,7 +191,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(504, 322);
this.picPng.Size = new System.Drawing.Size(511, 371);
this.picPng.TabIndex = 2;
this.picPng.TabStop = false;
//
......@@ -207,7 +207,7 @@
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(3, 335);
this.label4.Location = new System.Drawing.Point(3, 384);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(69, 13);
this.label4.TabIndex = 4;
......@@ -217,7 +217,7 @@
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1235, 676);
this.ClientSize = new System.Drawing.Size(1249, 774);
this.Controls.Add(this.tableLayoutPanel1);
this.Name = "View";
this.Text = "Form1";
......@@ -227,7 +227,7 @@
this.splitContainer1.ResumeLayout(false);
this.tableLayoutPanel2.ResumeLayout(false);
this.tableLayoutPanel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.picLoadSave)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.picSaveLoad)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.picSvg)).EndInit();
this.tableLayoutPanel3.ResumeLayout(false);
this.tableLayoutPanel3.PerformLayout();
......@@ -249,7 +249,7 @@
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3;
private System.Windows.Forms.PictureBox picPng;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.PictureBox picLoadSave;
private System.Windows.Forms.PictureBox picSaveLoad;
private System.Windows.Forms.PictureBox picSVGPNG;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
......
......@@ -35,13 +35,19 @@ namespace SvgW3CTestRunner
private void lstFiles_SelectedIndexChanged(object sender, EventArgs e)
{
//render svg
var fileName = lstFiles.SelectedItem.ToString();
if (fileName.StartsWith("#")) return;
//display png
var png = Image.FromFile(_pngBasePath + Path.GetFileNameWithoutExtension(fileName) + ".png");
picPng.Image = png;
var doc = new SvgDocument();
try
{
Debug.Print(fileName);
var doc = SvgDocument.Open(_svgBasePath + fileName);
doc = SvgDocument.Open(_svgBasePath + fileName);
if (fileName.StartsWith("__"))
{
picSvg.Image = doc.Draw();
......@@ -53,7 +59,16 @@ namespace SvgW3CTestRunner
picSvg.Image = img;
}
//save load
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "SVG Rendering");
picSvg.Image = null;
}
//save load
try
{
using(var memStream = new MemoryStream())
{
doc.Write(memStream);
......@@ -62,25 +77,34 @@ namespace SvgW3CTestRunner
if (fileName.StartsWith("__"))
{
picSvg.Image = doc.Draw();
picSaveLoad.Image = doc.Draw();
}
else
{
var img = new Bitmap(480, 360);
doc.Draw(img);
picSvg.Image = img;
picSaveLoad.Image = img;
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "SVG Serialization");
picSaveLoad.Image = null;
}
//compare svg to png
try
{
picSVGPNG.Image = PixelDiff((Bitmap)picSvg.Image, (Bitmap)picPng.Image);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
picSvg.Image = null;
MessageBox.Show(ex.ToString(), "SVG Comparison");
picSVGPNG.Image = null;
}
var png = Image.FromFile(_pngBasePath + Path.GetFileNameWithoutExtension(fileName) + ".png");
picPng.Image = png;
}
unsafe Bitmap PixelDiff(Bitmap a, Bitmap b)
......
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