public void AdjustMoistureMap() { MoistureMap.LockBits(); Map.LockBits(); for (int x = 0; x < MoistureMap.Width; x++) { for (int y = 0; y < MoistureMap.Height; y++) { float orig = (float)MoistureMap.GetPixel(x, y).R / 255.0f; float height = Map.GetHeight(x * 4, y * 4) / 255.0f; if (height * 255.0f < 102) { orig = 1.0f; } if (orig > 1.0f) { orig = 1.0f; } height = 1.0f - height; if (height > 0.54f) { orig = (orig + orig + 1) / 3.0f; } MoistureMap.SetPixel(x, y, Color.FromArgb(255, (int)(255 * orig), (int)(255 * orig), (int)(255 * orig))); } } Map.UnlockBits(); MoistureMap.UnlockBits(); MoistureMap.ResizeImage(MoistureMap.Source.Width / 16, MoistureMap.Source.Height / 16); MoistureMap.ResizeImage(Width, Height); // MoistureMap.Save24(Globals.MapOutputTotalDir + "moisture.bmp"); }
private float GetMoisture(int x, int y) { return(MoistureMap.GetPixel(x / 4, y / 4).R / 255.0f); }