Add bitmap export to palette (for debugging).

This commit is contained in:
Paul Chote
2013-02-21 23:38:19 +13:00
parent 2d10f6b739
commit 0287993c31

View File

@@ -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))