diff --git a/OpenRA.FileFormats/Palette.cs b/OpenRA.FileFormats/Palette.cs index 1202dc8f70..be5bf5e6bf 100644 --- a/OpenRA.FileFormats/Palette.cs +++ b/OpenRA.FileFormats/Palette.cs @@ -100,6 +100,21 @@ namespace OpenRA.FileFormats return pal; } + public Bitmap AsBitmap() + { + var b = new Bitmap(256, 1, PixelFormat.Format32bppArgb); + var data = b.LockBits(new Rectangle(0, 0, b.Width, b.Height), + ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); + unsafe + { + uint* c = (uint*)data.Scan0; + for (var x = 0; x < 256; x++) + *(c + x) = colors[x]; + } + b.UnlockBits(data); + return b; + } + public static Palette Load(string filename, int[] remap) { using(var s = File.OpenRead(filename))