diff --git a/OpenRa.sln b/OpenRa.sln index 1ef2b24136..39f8228def 100644 --- a/OpenRa.sln +++ b/OpenRa.sln @@ -9,28 +9,116 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRa.DataStructures", "Op EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PaletteUsage", "PaletteUsage\PaletteUsage.csproj", "{54577061-E2D2-4336-90A2-A9A7106A30CD}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PaletteMatch", "PaletteMatch\PaletteMatch.csproj", "{31411761-224C-4C54-A5FE-280890A70259}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug (x86)|Any CPU = Debug (x86)|Any CPU + Debug (x86)|Mixed Platforms = Debug (x86)|Mixed Platforms Debug (x86)|Win32 = Debug (x86)|Win32 + Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms + Debug|Win32 = Debug|Win32 + Release (x86)|Any CPU = Release (x86)|Any CPU + Release (x86)|Mixed Platforms = Release (x86)|Mixed Platforms Release (x86)|Win32 = Release (x86)|Win32 + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms + Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BDAEAB25-991E-46A7-AF1E-4F0E03358DAA}.Debug (x86)|Any CPU.ActiveCfg = Debug|x86 + {BDAEAB25-991E-46A7-AF1E-4F0E03358DAA}.Debug (x86)|Mixed Platforms.ActiveCfg = Debug|x86 + {BDAEAB25-991E-46A7-AF1E-4F0E03358DAA}.Debug (x86)|Mixed Platforms.Build.0 = Debug|x86 {BDAEAB25-991E-46A7-AF1E-4F0E03358DAA}.Debug (x86)|Win32.ActiveCfg = Debug|x86 {BDAEAB25-991E-46A7-AF1E-4F0E03358DAA}.Debug (x86)|Win32.Build.0 = Debug|x86 + {BDAEAB25-991E-46A7-AF1E-4F0E03358DAA}.Debug|Any CPU.ActiveCfg = Debug|x86 + {BDAEAB25-991E-46A7-AF1E-4F0E03358DAA}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {BDAEAB25-991E-46A7-AF1E-4F0E03358DAA}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {BDAEAB25-991E-46A7-AF1E-4F0E03358DAA}.Debug|Win32.ActiveCfg = Debug|x86 + {BDAEAB25-991E-46A7-AF1E-4F0E03358DAA}.Release (x86)|Any CPU.ActiveCfg = Release|x86 + {BDAEAB25-991E-46A7-AF1E-4F0E03358DAA}.Release (x86)|Mixed Platforms.ActiveCfg = Release|x86 + {BDAEAB25-991E-46A7-AF1E-4F0E03358DAA}.Release (x86)|Mixed Platforms.Build.0 = Release|x86 {BDAEAB25-991E-46A7-AF1E-4F0E03358DAA}.Release (x86)|Win32.ActiveCfg = Release|x86 {BDAEAB25-991E-46A7-AF1E-4F0E03358DAA}.Release (x86)|Win32.Build.0 = Release|x86 + {BDAEAB25-991E-46A7-AF1E-4F0E03358DAA}.Release|Any CPU.ActiveCfg = Release|x86 + {BDAEAB25-991E-46A7-AF1E-4F0E03358DAA}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {BDAEAB25-991E-46A7-AF1E-4F0E03358DAA}.Release|Mixed Platforms.Build.0 = Release|x86 + {BDAEAB25-991E-46A7-AF1E-4F0E03358DAA}.Release|Win32.ActiveCfg = Release|x86 + {0DFB103F-2962-400F-8C6D-E2C28CCBA633}.Debug (x86)|Any CPU.ActiveCfg = Debug|x86 + {0DFB103F-2962-400F-8C6D-E2C28CCBA633}.Debug (x86)|Mixed Platforms.ActiveCfg = Debug|x86 + {0DFB103F-2962-400F-8C6D-E2C28CCBA633}.Debug (x86)|Mixed Platforms.Build.0 = Debug|x86 {0DFB103F-2962-400F-8C6D-E2C28CCBA633}.Debug (x86)|Win32.ActiveCfg = Debug|x86 {0DFB103F-2962-400F-8C6D-E2C28CCBA633}.Debug (x86)|Win32.Build.0 = Debug|x86 + {0DFB103F-2962-400F-8C6D-E2C28CCBA633}.Debug|Any CPU.ActiveCfg = Debug|x86 + {0DFB103F-2962-400F-8C6D-E2C28CCBA633}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {0DFB103F-2962-400F-8C6D-E2C28CCBA633}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {0DFB103F-2962-400F-8C6D-E2C28CCBA633}.Debug|Win32.ActiveCfg = Debug|x86 + {0DFB103F-2962-400F-8C6D-E2C28CCBA633}.Release (x86)|Any CPU.ActiveCfg = Release|x86 + {0DFB103F-2962-400F-8C6D-E2C28CCBA633}.Release (x86)|Mixed Platforms.ActiveCfg = Release|x86 + {0DFB103F-2962-400F-8C6D-E2C28CCBA633}.Release (x86)|Mixed Platforms.Build.0 = Release|x86 {0DFB103F-2962-400F-8C6D-E2C28CCBA633}.Release (x86)|Win32.ActiveCfg = Release|x86 {0DFB103F-2962-400F-8C6D-E2C28CCBA633}.Release (x86)|Win32.Build.0 = Release|x86 + {0DFB103F-2962-400F-8C6D-E2C28CCBA633}.Release|Any CPU.ActiveCfg = Release|x86 + {0DFB103F-2962-400F-8C6D-E2C28CCBA633}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {0DFB103F-2962-400F-8C6D-E2C28CCBA633}.Release|Mixed Platforms.Build.0 = Release|x86 + {0DFB103F-2962-400F-8C6D-E2C28CCBA633}.Release|Win32.ActiveCfg = Release|x86 + {2F9E7A23-56C0-4286-9C8E-1060A9B2F073}.Debug (x86)|Any CPU.ActiveCfg = Debug|x86 + {2F9E7A23-56C0-4286-9C8E-1060A9B2F073}.Debug (x86)|Mixed Platforms.ActiveCfg = Debug|x86 + {2F9E7A23-56C0-4286-9C8E-1060A9B2F073}.Debug (x86)|Mixed Platforms.Build.0 = Debug|x86 {2F9E7A23-56C0-4286-9C8E-1060A9B2F073}.Debug (x86)|Win32.ActiveCfg = Debug|x86 {2F9E7A23-56C0-4286-9C8E-1060A9B2F073}.Debug (x86)|Win32.Build.0 = Debug|x86 + {2F9E7A23-56C0-4286-9C8E-1060A9B2F073}.Debug|Any CPU.ActiveCfg = Debug|x86 + {2F9E7A23-56C0-4286-9C8E-1060A9B2F073}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {2F9E7A23-56C0-4286-9C8E-1060A9B2F073}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {2F9E7A23-56C0-4286-9C8E-1060A9B2F073}.Debug|Win32.ActiveCfg = Debug|x86 + {2F9E7A23-56C0-4286-9C8E-1060A9B2F073}.Release (x86)|Any CPU.ActiveCfg = Release|x86 + {2F9E7A23-56C0-4286-9C8E-1060A9B2F073}.Release (x86)|Mixed Platforms.ActiveCfg = Release|x86 + {2F9E7A23-56C0-4286-9C8E-1060A9B2F073}.Release (x86)|Mixed Platforms.Build.0 = Release|x86 {2F9E7A23-56C0-4286-9C8E-1060A9B2F073}.Release (x86)|Win32.ActiveCfg = Release|x86 {2F9E7A23-56C0-4286-9C8E-1060A9B2F073}.Release (x86)|Win32.Build.0 = Release|x86 + {2F9E7A23-56C0-4286-9C8E-1060A9B2F073}.Release|Any CPU.ActiveCfg = Release|x86 + {2F9E7A23-56C0-4286-9C8E-1060A9B2F073}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {2F9E7A23-56C0-4286-9C8E-1060A9B2F073}.Release|Mixed Platforms.Build.0 = Release|x86 + {2F9E7A23-56C0-4286-9C8E-1060A9B2F073}.Release|Win32.ActiveCfg = Release|x86 + {54577061-E2D2-4336-90A2-A9A7106A30CD}.Debug (x86)|Any CPU.ActiveCfg = Debug|x86 + {54577061-E2D2-4336-90A2-A9A7106A30CD}.Debug (x86)|Mixed Platforms.ActiveCfg = Debug|x86 + {54577061-E2D2-4336-90A2-A9A7106A30CD}.Debug (x86)|Mixed Platforms.Build.0 = Debug|x86 {54577061-E2D2-4336-90A2-A9A7106A30CD}.Debug (x86)|Win32.ActiveCfg = Debug|x86 {54577061-E2D2-4336-90A2-A9A7106A30CD}.Debug (x86)|Win32.Build.0 = Debug|x86 + {54577061-E2D2-4336-90A2-A9A7106A30CD}.Debug|Any CPU.ActiveCfg = Debug|x86 + {54577061-E2D2-4336-90A2-A9A7106A30CD}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {54577061-E2D2-4336-90A2-A9A7106A30CD}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {54577061-E2D2-4336-90A2-A9A7106A30CD}.Debug|Win32.ActiveCfg = Debug|x86 + {54577061-E2D2-4336-90A2-A9A7106A30CD}.Release (x86)|Any CPU.ActiveCfg = Release|x86 + {54577061-E2D2-4336-90A2-A9A7106A30CD}.Release (x86)|Mixed Platforms.ActiveCfg = Release|x86 + {54577061-E2D2-4336-90A2-A9A7106A30CD}.Release (x86)|Mixed Platforms.Build.0 = Release|x86 {54577061-E2D2-4336-90A2-A9A7106A30CD}.Release (x86)|Win32.ActiveCfg = Release|x86 {54577061-E2D2-4336-90A2-A9A7106A30CD}.Release (x86)|Win32.Build.0 = Release|x86 + {54577061-E2D2-4336-90A2-A9A7106A30CD}.Release|Any CPU.ActiveCfg = Release|x86 + {54577061-E2D2-4336-90A2-A9A7106A30CD}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {54577061-E2D2-4336-90A2-A9A7106A30CD}.Release|Mixed Platforms.Build.0 = Release|x86 + {54577061-E2D2-4336-90A2-A9A7106A30CD}.Release|Win32.ActiveCfg = Release|x86 + {31411761-224C-4C54-A5FE-280890A70259}.Debug (x86)|Any CPU.ActiveCfg = Debug|Any CPU + {31411761-224C-4C54-A5FE-280890A70259}.Debug (x86)|Any CPU.Build.0 = Debug|Any CPU + {31411761-224C-4C54-A5FE-280890A70259}.Debug (x86)|Mixed Platforms.ActiveCfg = Debug|Any CPU + {31411761-224C-4C54-A5FE-280890A70259}.Debug (x86)|Mixed Platforms.Build.0 = Debug|Any CPU + {31411761-224C-4C54-A5FE-280890A70259}.Debug (x86)|Win32.ActiveCfg = Debug|Any CPU + {31411761-224C-4C54-A5FE-280890A70259}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {31411761-224C-4C54-A5FE-280890A70259}.Debug|Any CPU.Build.0 = Debug|Any CPU + {31411761-224C-4C54-A5FE-280890A70259}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {31411761-224C-4C54-A5FE-280890A70259}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {31411761-224C-4C54-A5FE-280890A70259}.Debug|Win32.ActiveCfg = Debug|Any CPU + {31411761-224C-4C54-A5FE-280890A70259}.Release (x86)|Any CPU.ActiveCfg = Release|Any CPU + {31411761-224C-4C54-A5FE-280890A70259}.Release (x86)|Any CPU.Build.0 = Release|Any CPU + {31411761-224C-4C54-A5FE-280890A70259}.Release (x86)|Mixed Platforms.ActiveCfg = Release|Any CPU + {31411761-224C-4C54-A5FE-280890A70259}.Release (x86)|Mixed Platforms.Build.0 = Release|Any CPU + {31411761-224C-4C54-A5FE-280890A70259}.Release (x86)|Win32.ActiveCfg = Release|Any CPU + {31411761-224C-4C54-A5FE-280890A70259}.Release|Any CPU.ActiveCfg = Release|Any CPU + {31411761-224C-4C54-A5FE-280890A70259}.Release|Any CPU.Build.0 = Release|Any CPU + {31411761-224C-4C54-A5FE-280890A70259}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {31411761-224C-4C54-A5FE-280890A70259}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {31411761-224C-4C54-A5FE-280890A70259}.Release|Win32.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/PaletteMatch/PaletteMatch.csproj b/PaletteMatch/PaletteMatch.csproj new file mode 100644 index 0000000000..4b973ee838 --- /dev/null +++ b/PaletteMatch/PaletteMatch.csproj @@ -0,0 +1,66 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {31411761-224C-4C54-A5FE-280890A70259} + Exe + Properties + PaletteMatch + PaletteMatch + v3.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + 3.5 + + + + 3.5 + + + 3.5 + + + + + + + + + + + {BDAEAB25-991E-46A7-AF1E-4F0E03358DAA} + OpenRa.FileFormats + + + + + \ No newline at end of file diff --git a/PaletteMatch/Program.cs b/PaletteMatch/Program.cs new file mode 100644 index 0000000000..ab6ba92dee --- /dev/null +++ b/PaletteMatch/Program.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.IO; +using OpenRa.FileFormats; +using System.Drawing; + +namespace PaletteMatch +{ + /* a simple little hack to work out a sane matching between TD and RA palettes (or, indeed, from RA -> RA) */ + /* usage: PaletteMatch srcpal destpal */ + + static class Program + { + static void Main(string[] args) + { + var tdPalette = WithStream(args[0], s => new Palette(s)); + var raPalette = WithStream(args[1], s => new Palette(s)); + + var ms = tdPalette.Entries().Select( + (a, i) => new + { + Src = i, + Dest = raPalette.Entries().Select( + (b, j) => new { Color = b, Index = j }) + .OrderBy(x => x.Color, new ColorDistanceComparer(a)).First().Index + }); + + foreach( var m in ms ) + Console.WriteLine("{0:x2} -> {1:x2}", m.Src, m.Dest); + } + + static IEnumerable Entries(this Palette p) + { + for (var i = 0; i < 256; i++) + yield return p.GetColor(i); + } + + static T WithStream(string filename, Func f) + { + using (var s = File.OpenRead(filename)) + return f(s); + } + } + + class ColorDistanceComparer : IComparer + { + readonly Color r; + + public ColorDistanceComparer(Color r) + { + this.r = r; + } + + float Distance(Color a) + { + var b = a.GetBrightness() - r.GetBrightness(); + var h = a.GetHue() - r.GetHue(); + var s = a.GetSaturation() - r.GetSaturation(); + + return b * b + h * h + s * s; + } + + public int Compare(Color x, Color y) + { + return Math.Sign(Distance(x) - Distance(y)); + } + } + +} diff --git a/PaletteMatch/Properties/AssemblyInfo.cs b/PaletteMatch/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..2f6ead4761 --- /dev/null +++ b/PaletteMatch/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("PaletteMatch")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("PaletteMatch")] +[assembly: AssemblyCopyright("Copyright © 2009")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("eb944988-f387-46a5-bb5b-392d482df964")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/tdbits/a10.shp b/tdbits/a10.shp new file mode 100644 index 0000000000..71b4dbd85d Binary files /dev/null and b/tdbits/a10.shp differ diff --git a/tdbits/a10icnh.win b/tdbits/a10icnh.win new file mode 100644 index 0000000000..48ddd4e516 Binary files /dev/null and b/tdbits/a10icnh.win differ diff --git a/tdbits/winter.pal b/tdbits/winter.pal new file mode 100644 index 0000000000..3b29c55f5a Binary files /dev/null and b/tdbits/winter.pal differ