diff --git a/OpenRA.Game/FileFormats/Png.cs b/OpenRA.Game/FileFormats/Png.cs index 508236fead..1b73567dce 100644 --- a/OpenRA.Game/FileFormats/Png.cs +++ b/OpenRA.Game/FileFormats/Png.cs @@ -161,6 +161,25 @@ namespace OpenRA.FileFormats } } + public Png(byte[] data, int width, int height, Color[] palette = null, + Dictionary embeddedData = null) + { + var expectLength = width * height; + if (palette == null) + expectLength *= 4; + + if (data.Length != expectLength) + throw new InvalidDataException("Input data does not match expected length"); + Width = width; + Height = height; + + Palette = palette; + Data = data; + + if (embeddedData != null) + EmbeddedData = embeddedData; + } + public static bool Verify(Stream s) { var pos = s.Position;