Created
May 21, 2021 14:42
-
-
Save WamWooWam/9a27a27a7fead01b828c3e83767c4393 to your computer and use it in GitHub Desktop.
Small tool to extract backgrounds from LiveSplit LSL files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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