From 0287993c31d6ca217b75eda9df2917a92e14d6b8 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Thu, 21 Feb 2013 23:38:19 +1300 Subject: [PATCH] Add bitmap export to palette (for debugging). --- OpenRA.FileFormats/Palette.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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))