add d2k -> ra shp conversion support to utility

This commit is contained in:
Chris Forbes
2011-07-17 18:37:12 +12:00
parent 239be241ff
commit 2a16172a20
2 changed files with 21 additions and 0 deletions

View File

@@ -13,6 +13,7 @@ using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using OpenRA.FileFormats;
@@ -122,5 +123,24 @@ namespace OpenRA.Utility
bitmap.Save(dest);
}
}
public static void ConvertFormat2ToFormat80(string[] args)
{
var src = args[1];
var dest = args[2];
Dune2ShpReader srcImage = null;
using( var s = File.OpenRead( src ) )
srcImage = new Dune2ShpReader(s);
var size = srcImage.First().Size;
if (!srcImage.All( im => im.Size == size ))
throw new InvalidOperationException("All the frames must be the same size to convert from Dune2 to RA");
using( var destStream = File.Create(dest) )
ShpWriter.Write(destStream, size.Width, size.Height,
srcImage.Select( im => im.Image ));
}
}
}

View File

@@ -25,6 +25,7 @@ namespace OpenRA.Utility
{ "--settings-value", Command.Settings },
{ "--shp", Command.ConvertPngToShp },
{ "--png", Command.ConvertShpToPng },
{ "--fromd2", Command.ConvertFormat2ToFormat80 },
};
if (args.Length == 0) { PrintUsage(); return; }