Skip to content

Instantly share code, notes, and snippets.

@WamWooWam
Created May 21, 2021 14:42
Show Gist options
  • Save WamWooWam/9a27a27a7fead01b828c3e83767c4393 to your computer and use it in GitHub Desktop.
Save WamWooWam/9a27a27a7fead01b828c3e83767c4393 to your computer and use it in GitHub Desktop.
Small tool to extract backgrounds from LiveSplit LSL files
using System;
using System.IO;
using System.Drawing;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Xml;
class Program
{
static void Main(string[] args)
{
foreach (var item in args)
{
var bf = new BinaryFormatter();
var xmlDoc = new XmlDocument();
xmlDoc.Load(item);
var element = xmlDoc.SelectSingleNode("//BackgroundImage");
if (element == null)
continue;
var data = Convert.FromBase64String(element.InnerText);
if (data.Length == 0)
continue;
using (var ms = new MemoryStream(data))
{
((Image)bf.Deserialize(ms)).Save(Path.ChangeExtension(item, "png"));
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment