public static void PaintCoast() { Bitmap img = LoadImage("terrain.bmp"); var p = img.Palette; p.Entries[10] = Color.FromArgb(255, 247, 0); img.Palette = p; LockBitmap lockImg = new LockBitmap(img); lockImg.LockBits(); int pixelsPainted = 0; bool[] matchData = new bool[lockImg.Width * lockImg.Height]; for (int y = 0; y < lockImg.Height; y++) { for (int x = 0; x < lockImg.Width; x++) { Console.SetCursorPosition(0, 0); Console.WriteLine("Checking pixel (" + x + ", " + y + ")"); if (IsCoastPixel(x, y, lockImg, matchData)) { lockImg.SetPixel(x, y, Color.FromArgb(255, 247, 0)); pixelsPainted++; Console.WriteLine("Pixels Painted: " + pixelsPainted); } } } lockImg.UnlockBits(); SaveImage(img, "terrain_coast.bmp"); }
public static void PaintHeightmap() { Bitmap terrain = LoadImage("terrain_eu3.bmp"); Bitmap heightmap = LoadImage("heightmap.bmp"); LockBitmap lockT = new LockBitmap(terrain); LockBitmap lockH = new LockBitmap(heightmap); lockT.LockBits(); lockH.LockBits(); var tablePalette = new Dictionary <Color, int>(); for (int i = 0; i < terrain.Palette.Entries.Length; i++) { if (!tablePalette.ContainsKey(terrain.Palette.Entries[i])) { tablePalette.Add(terrain.Palette.Entries[i], i); } } for (int y = 0; y < lockT.Height; y++) { for (int x = 0; x < lockT.Width; x++) { Console.SetCursorPosition(0, 0); Console.WriteLine("At pixel (" + x + ", " + y + ")"); var c = lockT.GetPixel(x, y); int indexIn = tablePalette.ContainsKey(c) ? tablePalette[lockT.GetPixel(x, y)] : 0; int height = GetHeight((TerrainCategoriesEU3)indexIn); lockH.SetPixel(x, y, Color.FromArgb(height, height, height)); } } lockT.UnlockBits(); lockH.UnlockBits(); SaveImage(heightmap, "heightmap_new.bmp"); }