Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Fields
- Form myForm = new Form();
- //Initialize
- System.Windows.Forms.Application.EnableVisualStyles();
- Task.Run(() =>System.Windows.Forms.Application.Run(myForm));
- //Update
- for (int x = 0; x < GameManager.Instance.MapSize.x; x++)
- {
- for (int y = 0; y < GameManager.Instance.MapSize.y; y++)
- {
- TerrainAnalysis[x, y] = UnityEngine.Random.Range(0f, 1f);
- }
- }
- CreateBitmapOfTerrainAnalysis(TerrainAnalysis, "TerrainAnalysis");
- //drawing bitmap method... Specifically the last 2 lines.
- /// <summary>
- /// Creates a bitmap file of your terrain.
- /// </summary>
- /// <param name="terrain">The float array used to represent the terrain map. If you used a different data structure, modify this method to accept it.</param>
- /// <param name="fileName">The name of the file. Do not include a file extension</param>
- private void CreateBitmapOfTerrainAnalysis(float[,] terrain, string fileName)
- {
- System.Drawing.Bitmap b = new System.Drawing.Bitmap(GameManager.Instance.MapSize.x, GameManager.Instance.MapSize.y);
- for (int x = 0; x < GameManager.Instance.MapSize.x; x++)
- {
- for (int y = 0; y < GameManager.Instance.MapSize.y; y++)
- {
- b.SetPixel(x, y, System.Drawing.Color.FromArgb((int)(terrain[x, y] * 255), (int)(terrain[x, y] * 255), (int)(terrain[x, y] * 255)));
- }
- }
- b.Save(fileName + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
- System.Drawing.Graphics g = myForm.CreateGraphics();
- g.DrawImage(b, new Point(0, 0));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement