Commit 4898799d authored by tebjan's avatar tebjan
Browse files

added save/load routine to W3C tester, fixed a bug in attribute writing

parent 0d2b50e7
...@@ -23,8 +23,9 @@ namespace Svg ...@@ -23,8 +23,9 @@ namespace Svg
public static readonly List<KeyValuePair<string, string>> Namespaces = new List<KeyValuePair<string, string>>() public static readonly List<KeyValuePair<string, string>> Namespaces = new List<KeyValuePair<string, string>>()
{ {
new KeyValuePair<string, string>("", SvgNamespace), new KeyValuePair<string, string>("", SvgNamespace),
new KeyValuePair<string, string>(XLinkPrefix, XLinkNamespace) new KeyValuePair<string, string>(XLinkPrefix, XLinkNamespace),
}; new KeyValuePair<string, string>("xml", XmlNamespace)
};
private string _name; private string _name;
private string _namespace; private string _namespace;
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform> <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion> <ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion> <SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{8ED74C39-6CFF-421E-952A-30F9E6957108}</ProjectGuid> <ProjectGuid>{8ED74C39-6CFF-421E-952A-30F9E6957108}</ProjectGuid>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SvgW3CTestRunner</RootNamespace> <RootNamespace>SvgW3CTestRunner</RootNamespace>
<AssemblyName>SvgW3CTestRunner</AssemblyName> <AssemblyName>SvgW3CTestRunner</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
</PropertyGroup> <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> <NoStdLib>False</NoStdLib>
<PlatformTarget>x86</PlatformTarget> <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<DebugSymbols>true</DebugSymbols> <IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DebugType>full</DebugType> </PropertyGroup>
<Optimize>false</Optimize> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<OutputPath>bin\Debug\</OutputPath> <PlatformTarget>x86</PlatformTarget>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DebugSymbols>true</DebugSymbols>
<ErrorReport>prompt</ErrorReport> <DebugType>Full</DebugType>
<WarningLevel>4</WarningLevel> <Optimize>False</Optimize>
</PropertyGroup> <OutputPath>bin\Debug\</OutputPath>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> <DefineConstants>DEBUG;TRACE</DefineConstants>
<PlatformTarget>x86</PlatformTarget> <ErrorReport>prompt</ErrorReport>
<DebugType>pdbonly</DebugType> <WarningLevel>4</WarningLevel>
<Optimize>true</Optimize> </PropertyGroup>
<OutputPath>bin\Release\</OutputPath> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<DefineConstants>TRACE</DefineConstants> <PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport> <DebugType>pdbonly</DebugType>
<WarningLevel>4</WarningLevel> <Optimize>true</Optimize>
</PropertyGroup> <OutputPath>bin\Release\</OutputPath>
<ItemGroup> <DefineConstants>TRACE</DefineConstants>
<Reference Include="System" /> <ErrorReport>prompt</ErrorReport>
<Reference Include="System.Core" /> <WarningLevel>4</WarningLevel>
<Reference Include="System.Xml.Linq" /> </PropertyGroup>
<Reference Include="System.Data.DataSetExtensions" /> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<Reference Include="System.Data" /> <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<Reference Include="System.Deployment" /> <BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
<Reference Include="System.Drawing" /> </PropertyGroup>
<Reference Include="System.Windows.Forms" /> <PropertyGroup Condition=" '$(Platform)' == 'x86' ">
<Reference Include="System.Xml" /> <BaseAddress>4194304</BaseAddress>
</ItemGroup> <RegisterForComInterop>False</RegisterForComInterop>
<ItemGroup> <GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<Compile Include="View.cs"> </PropertyGroup>
<SubType>Form</SubType> <ItemGroup>
</Compile> <Reference Include="System" />
<Compile Include="View.Designer.cs"> <Reference Include="System.Core" />
<DependentUpon>View.cs</DependentUpon> <Reference Include="System.Xml.Linq" />
</Compile> <Reference Include="System.Data.DataSetExtensions" />
<Compile Include="Program.cs" /> <Reference Include="System.Data" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Reference Include="System.Deployment" />
<EmbeddedResource Include="View.resx"> <Reference Include="System.Drawing" />
<DependentUpon>View.cs</DependentUpon> <Reference Include="System.Windows.Forms" />
</EmbeddedResource> <Reference Include="System.Xml" />
<EmbeddedResource Include="Properties\Resources.resx"> </ItemGroup>
<Generator>ResXFileCodeGenerator</Generator> <ItemGroup>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <Compile Include="View.cs">
<SubType>Designer</SubType> <SubType>Form</SubType>
</EmbeddedResource> </Compile>
<Compile Include="Properties\Resources.Designer.cs"> <Compile Include="View.Designer.cs">
<AutoGen>True</AutoGen> <DependentUpon>View.cs</DependentUpon>
<DependentUpon>Resources.resx</DependentUpon> </Compile>
</Compile> <Compile Include="Program.cs" />
<None Include="Properties\Settings.settings"> <Compile Include="Properties\AssemblyInfo.cs" />
<Generator>SettingsSingleFileGenerator</Generator> <EmbeddedResource Include="View.resx">
<LastGenOutput>Settings.Designer.cs</LastGenOutput> <DependentUpon>View.cs</DependentUpon>
</None> </EmbeddedResource>
<Compile Include="Properties\Settings.Designer.cs"> <EmbeddedResource Include="Properties\Resources.resx">
<AutoGen>True</AutoGen> <Generator>ResXFileCodeGenerator</Generator>
<DependentUpon>Settings.settings</DependentUpon> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
<DesignTimeSharedInput>True</DesignTimeSharedInput> <SubType>Designer</SubType>
</Compile> </EmbeddedResource>
</ItemGroup> <Compile Include="Properties\Resources.Designer.cs">
<ItemGroup> <AutoGen>True</AutoGen>
<ProjectReference Include="..\..\Source\Svg.csproj"> <DependentUpon>Resources.resx</DependentUpon>
<Project>{886A98C5-37C0-4E8B-885E-30C1D2F98B47}</Project> </Compile>
<Name>Svg</Name> <None Include="Properties\Settings.settings">
</ProjectReference> <Generator>SettingsSingleFileGenerator</Generator>
</ItemGroup> <LastGenOutput>Settings.Designer.cs</LastGenOutput>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> </None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Source\Svg.csproj">
<Project>{886A98C5-37C0-4E8B-885E-30C1D2F98B47}</Project>
<Name>Svg</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild"> <Target Name="BeforeBuild">
</Target> </Target>
<Target Name="AfterBuild"> <Target Name="AfterBuild">
</Target> </Target>
--> -->
</Project> </Project>
\ No newline at end of file
...@@ -32,18 +32,24 @@ ...@@ -32,18 +32,24 @@
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
this.picLoadSave = new System.Windows.Forms.PictureBox();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.picSvg = new System.Windows.Forms.PictureBox(); this.picSvg = new System.Windows.Forms.PictureBox();
this.label3 = new System.Windows.Forms.Label();
this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel(); this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel();
this.picSVGPNG = new System.Windows.Forms.PictureBox();
this.picPng = new System.Windows.Forms.PictureBox(); this.picPng = new System.Windows.Forms.PictureBox();
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.tableLayoutPanel1.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout();
this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout(); this.splitContainer1.SuspendLayout();
this.tableLayoutPanel2.SuspendLayout(); this.tableLayoutPanel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picLoadSave)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.picSvg)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.picSvg)).BeginInit();
this.tableLayoutPanel3.SuspendLayout(); this.tableLayoutPanel3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picSVGPNG)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.picPng)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.picPng)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
...@@ -92,18 +98,33 @@ ...@@ -92,18 +98,33 @@
// tableLayoutPanel2 // tableLayoutPanel2
// //
this.tableLayoutPanel2.ColumnCount = 1; this.tableLayoutPanel2.ColumnCount = 1;
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); 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.label1, 0, 0); this.tableLayoutPanel2.Controls.Add(this.label1, 0, 0);
this.tableLayoutPanel2.Controls.Add(this.picSvg, 0, 1); this.tableLayoutPanel2.Controls.Add(this.picSvg, 0, 1);
this.tableLayoutPanel2.Controls.Add(this.label3, 0, 2);
this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel2.Location = new System.Drawing.Point(0, 0); this.tableLayoutPanel2.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel2.Name = "tableLayoutPanel2"; this.tableLayoutPanel2.Name = "tableLayoutPanel2";
this.tableLayoutPanel2.RowCount = 2; this.tableLayoutPanel2.RowCount = 4;
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.RowStyles.Add(new System.Windows.Forms.RowStyle()); 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.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(541, 670);
this.tableLayoutPanel2.TabIndex = 0; this.tableLayoutPanel2.TabIndex = 0;
// //
// picLoadSave
//
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;
//
// label1 // label1
// //
this.label1.AutoSize = true; this.label1.AutoSize = true;
...@@ -120,25 +141,49 @@ ...@@ -120,25 +141,49 @@
this.picSvg.Location = new System.Drawing.Point(0, 13); this.picSvg.Location = new System.Drawing.Point(0, 13);
this.picSvg.Margin = new System.Windows.Forms.Padding(0); this.picSvg.Margin = new System.Windows.Forms.Padding(0);
this.picSvg.Name = "picSvg"; this.picSvg.Name = "picSvg";
this.picSvg.Size = new System.Drawing.Size(541, 657); this.picSvg.Size = new System.Drawing.Size(541, 322);
this.picSvg.TabIndex = 1; this.picSvg.TabIndex = 1;
this.picSvg.TabStop = false; this.picSvg.TabStop = false;
// //
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(3, 335);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(80, 13);
this.label3.TabIndex = 3;
this.label3.Text = "Save and Load";
//
// tableLayoutPanel3 // tableLayoutPanel3
// //
this.tableLayoutPanel3.ColumnCount = 1; this.tableLayoutPanel3.ColumnCount = 1;
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel3.Controls.Add(this.picSVGPNG, 0, 3);
this.tableLayoutPanel3.Controls.Add(this.picPng, 0, 1); this.tableLayoutPanel3.Controls.Add(this.picPng, 0, 1);
this.tableLayoutPanel3.Controls.Add(this.label2, 0, 0); this.tableLayoutPanel3.Controls.Add(this.label2, 0, 0);
this.tableLayoutPanel3.Controls.Add(this.label4, 0, 2);
this.tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel3.Location = new System.Drawing.Point(0, 0); this.tableLayoutPanel3.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel3.Name = "tableLayoutPanel3"; this.tableLayoutPanel3.Name = "tableLayoutPanel3";
this.tableLayoutPanel3.RowCount = 2; this.tableLayoutPanel3.RowCount = 4;
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.RowStyles.Add(new System.Windows.Forms.RowStyle()); 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.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(504, 670);
this.tableLayoutPanel3.TabIndex = 0; 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.Margin = new System.Windows.Forms.Padding(0);
this.picSVGPNG.Name = "picSVGPNG";
this.picSVGPNG.Size = new System.Drawing.Size(504, 322);
this.picSVGPNG.TabIndex = 3;
this.picSVGPNG.TabStop = false;
//
// picPng // picPng
// //
this.picPng.BackColor = System.Drawing.Color.White; this.picPng.BackColor = System.Drawing.Color.White;
...@@ -146,7 +191,7 @@ ...@@ -146,7 +191,7 @@
this.picPng.Location = new System.Drawing.Point(0, 13); this.picPng.Location = new System.Drawing.Point(0, 13);
this.picPng.Margin = new System.Windows.Forms.Padding(0); this.picPng.Margin = new System.Windows.Forms.Padding(0);
this.picPng.Name = "picPng"; this.picPng.Name = "picPng";
this.picPng.Size = new System.Drawing.Size(504, 657); this.picPng.Size = new System.Drawing.Size(504, 322);
this.picPng.TabIndex = 2; this.picPng.TabIndex = 2;
this.picPng.TabStop = false; this.picPng.TabStop = false;
// //
...@@ -159,6 +204,15 @@ ...@@ -159,6 +204,15 @@
this.label2.TabIndex = 0; this.label2.TabIndex = 0;
this.label2.Text = "PNG Render"; this.label2.Text = "PNG Render";
// //
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(3, 335);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(69, 13);
this.label4.TabIndex = 4;
this.label4.Text = "SVG vs PNG";
//
// View // View
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
...@@ -173,13 +227,16 @@ ...@@ -173,13 +227,16 @@
this.splitContainer1.ResumeLayout(false); this.splitContainer1.ResumeLayout(false);
this.tableLayoutPanel2.ResumeLayout(false); this.tableLayoutPanel2.ResumeLayout(false);
this.tableLayoutPanel2.PerformLayout(); this.tableLayoutPanel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.picLoadSave)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.picSvg)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.picSvg)).EndInit();
this.tableLayoutPanel3.ResumeLayout(false); this.tableLayoutPanel3.ResumeLayout(false);
this.tableLayoutPanel3.PerformLayout(); this.tableLayoutPanel3.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.picSVGPNG)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.picPng)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.picPng)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
} }
#endregion #endregion
...@@ -192,6 +249,10 @@ ...@@ -192,6 +249,10 @@
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3;
private System.Windows.Forms.PictureBox picPng; private System.Windows.Forms.PictureBox picPng;
private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label2;
private System.Windows.Forms.PictureBox picLoadSave;
private System.Windows.Forms.PictureBox picSVGPNG;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
} }
} }
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing.Imaging;
using System.Linq; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using System.Drawing; using System.Drawing;
...@@ -20,11 +21,11 @@ namespace SvgW3CTestRunner ...@@ -20,11 +21,11 @@ namespace SvgW3CTestRunner
// ignore tests pertaining to javascript or xml reading // ignore tests pertaining to javascript or xml reading
var passes = File.ReadAllLines(_svgBasePath + @"..\PassingTests.txt").ToDictionary((f) => f, (f) => true); var passes = File.ReadAllLines(_svgBasePath + @"..\PassingTests.txt").ToDictionary((f) => f, (f) => true);
var files = (from f in var files = (from f in
(from g in Directory.GetFiles(_svgBasePath) (from g in Directory.GetFiles(_svgBasePath)
select Path.GetFileName(g)) select Path.GetFileName(g))
where !f.StartsWith("animate-") && !f.StartsWith("conform-viewer") && where !f.StartsWith("animate-") && !f.StartsWith("conform-viewer") &&
!f.Contains("-dom-") && !f.StartsWith("linking-") && !f.StartsWith("interact-") && !f.Contains("-dom-") && !f.StartsWith("linking-") && !f.StartsWith("interact-") &&
!f.StartsWith("script-") !f.StartsWith("script-")
orderby f orderby f
select (object)f); select (object)f);
files = files.Where((f) => !passes.ContainsKey((string)f)).Union(Enumerable.Repeat((object)"## PASSING ##", 1)).Union(files.Where((f) => passes.ContainsKey((string)f))); files = files.Where((f) => !passes.ContainsKey((string)f)).Union(Enumerable.Repeat((object)"## PASSING ##", 1)).Union(files.Where((f) => passes.ContainsKey((string)f)));
...@@ -36,20 +37,41 @@ namespace SvgW3CTestRunner ...@@ -36,20 +37,41 @@ namespace SvgW3CTestRunner
{ {
var fileName = lstFiles.SelectedItem.ToString(); var fileName = lstFiles.SelectedItem.ToString();
if (fileName.StartsWith("#")) return; if (fileName.StartsWith("#")) return;
try try
{ {
Debug.Print(fileName); Debug.Print(fileName);
var doc = SvgDocument.Open(_svgBasePath + fileName); var doc = SvgDocument.Open(_svgBasePath + fileName);
if (fileName.StartsWith("__")) if (fileName.StartsWith("__"))
{ {
picSvg.Image = doc.Draw(); picSvg.Image = doc.Draw();
} }
else else
{ {
var img = new Bitmap(480, 360); var img = new Bitmap(480, 360);
doc.Draw(img); doc.Draw(img);
picSvg.Image = img; picSvg.Image = img;
}
//save load
using(var memStream = new MemoryStream())
{
doc.Write(memStream);
memStream.Position = 0;
doc = SvgDocument.Open<SvgDocument>(memStream);
if (fileName.StartsWith("__"))
{
picSvg.Image = doc.Draw();
}
else
{
var img = new Bitmap(480, 360);
doc.Draw(img);
picSvg.Image = img;
}
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
...@@ -60,5 +82,90 @@ namespace SvgW3CTestRunner ...@@ -60,5 +82,90 @@ namespace SvgW3CTestRunner
var png = Image.FromFile(_pngBasePath + Path.GetFileNameWithoutExtension(fileName) + ".png"); var png = Image.FromFile(_pngBasePath + Path.GetFileNameWithoutExtension(fileName) + ".png");
picPng.Image = png; picPng.Image = png;
} }
unsafe Bitmap PixelDiff(Bitmap a, Bitmap b)
{
Bitmap output = new Bitmap(a.Width, a.Height, PixelFormat.Format32bppArgb);
Rectangle rect = new Rectangle(Point.Empty, a.Size);
using (var aData = a.LockBitsDisposable(rect, ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb))
using (var bData = b.LockBitsDisposable(rect, ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb))
using (var outputData = output.LockBitsDisposable(rect, ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb))
{
byte* aPtr = (byte*)aData.Scan0;
byte* bPtr = (byte*)bData.Scan0;
byte* outputPtr = (byte*)outputData.Scan0;
int len = aData.Stride * aData.Height;
for (int i = 0; i < len; i++)
{
// For alpha use the average of both images (otherwise pixels with the same alpha won't be visible)
if ((i + 1) % 4 == 0)
*outputPtr = (byte)((*aPtr + *bPtr) / 2);
else
*outputPtr = (byte)~(*aPtr ^ *bPtr);
outputPtr++;
aPtr++;
bPtr++;
}
}
return output;
}
}
static class BitmapExtensions
{
public static DisposableImageData LockBitsDisposable(this Bitmap bitmap, Rectangle rect, ImageLockMode flags, PixelFormat format)
{
return new DisposableImageData(bitmap, rect, flags, format);
}
public class DisposableImageData : IDisposable
{
private readonly Bitmap _bitmap;
private readonly BitmapData _data;
internal DisposableImageData(Bitmap bitmap, Rectangle rect, ImageLockMode flags, PixelFormat format)
{
_bitmap = bitmap;
_data = bitmap.LockBits(rect, flags, format);
}
public void Dispose()
{
_bitmap.UnlockBits(_data);
}
public IntPtr Scan0
{
get { return _data.Scan0; }
}
public int Stride
{
get { return _data.Stride;}
}
public int Width
{
get { return _data.Width;}
}
public int Height
{
get { return _data.Height;}
}
public PixelFormat PixelFormat
{
get { return _data.PixelFormat;}
}
public int Reserved
{
get { return _data.Reserved;}
}
}
} }
} }
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<!-- <!--
Microsoft ResX Schema Microsoft ResX Schema
Version 2.0 Version 2.0
The primary goals of this format is to allow a simple XML format The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes various data types are done through the TypeConverter classes
associated with the data types. associated with the data types.
Example: Example:
... ado.net/XML headers & schema ... ... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader> <resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader> <resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value> <value>[base64 mime encoded serialized .NET Framework object]</value>
</data> </data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment> <comment>This is a comment</comment>
</data> </data>
There are any number of "resheader" rows that contain simple There are any number of "resheader" rows that contain simple
name/value pairs. name/value pairs.
Each data row contains a name, and value. The row also contains a Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture. text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the Classes that don't support this are serialized and stored with the
mimetype set. mimetype set.
The mimetype is used for serialized objects, and tells the The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly: extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below. read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64 mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64 mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64 mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter : using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
--> -->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType> <xsd:complexType>
<xsd:choice maxOccurs="unbounded"> <xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata"> <xsd:element name="metadata">
<xsd:complexType> <xsd:complexType>
<xsd:sequence> <xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" /> <xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" /> <xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" /> <xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" /> <xsd:attribute ref="xml:space" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="assembly"> <xsd:element name="assembly">
<xsd:complexType> <xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" /> <xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" /> <xsd:attribute name="name" type="xsd:string" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="data"> <xsd:element name="data">
<xsd:complexType> <xsd:complexType>
<xsd:sequence> <xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" /> <xsd:attribute ref="xml:space" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="resheader"> <xsd:element name="resheader">
<xsd:complexType> <xsd:complexType>
<xsd:sequence> <xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" /> <xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
</xsd:choice> </xsd:choice>
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
</xsd:schema> </xsd:schema>
<resheader name="resmimetype"> <resheader name="resmimetype">
<value>text/microsoft-resx</value> <value>text/microsoft-resx</value>
</resheader> </resheader>
<resheader name="version"> <resheader name="version">
<value>2.0</value> <value>2.0</value>
</resheader> </resheader>
<resheader name="reader"> <resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
</root> </root>
\ 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