Any interest in mass image-to-PNG conversion?
analytik opened this issue · comments
Milan B commented
I'm not a C# developer, but I hacked together a feature that allows to open multiple TMX files at once, and then export them all as PNG
The gist of it is:
private void ExportAllTMXAsPNGToolStripMenuItemClickEventHandler(object sender, EventArgs e)
{
Console.WriteLine("Starting mass export as PNG.");
foreach (TreeNode node in mainTreeView.Nodes)
{
var resWrap = node as IResourceWrapper;
if (resWrap.Resource is ITextureFile)
{
// this is extremely lazy but I forgive you
var path = openToolStripMenuItem.DropDownItems[openToolStripMenuItem.DropDownItems.Count - 1].Text;
var lastSlashPosition = path.LastIndexOf('\\') + 1;
path = path.Substring(0, lastSlashPosition) + node.Text.Replace(".tmx", ".png");
//path = path.Replace(".tmx", ".png");
Console.WriteLine("Writing file {0}", path);
((ITextureFile)resWrap.Resource).GetBitmap().Save(path, ImageFormat.Png);
}
else
{
Console.WriteLine("Skipping a non-texture node: {0}", node.Text);
}
}
Console.WriteLine("Mass export as PNG finished.");
}
Is there any use in submitting a formal PR? I don't have the files committed yet.
Also, the main issue is memory leaking and the fact that amicitialibrary is 32 bit, therefore things start crashing after about 40 4MB TMX files, when the app reaches cca 1.7GB memory usage. I don't know how to fix that myself, I couldn't convert it to .NET 4.7 or newer myself.