private void importMapButton_Click(object sender, EventArgs e) { // show the file open dialog, and get the path from it DialogResult result = importMapDialog.ShowDialog(); if (result == DialogResult.OK) { if (importMapDialog.FileName.EndsWith(".tif")) { try { terrain = new Terrain(xSize, ySize, xMapSize, yMapSize, maxAlt); terrain.terrainFromTIFF(importMapDialog.FileName); } catch (IOException ex) { MessageBox.Show(ex.Message); } } else if (importMapDialog.FileName.EndsWith(".bmp")) { terrain = new Terrain(xSize, ySize, xMapSize, yMapSize, maxAlt); Bitmap inputBmp = new Bitmap(importMapDialog.FileName); terrain.terrainFromBmp(inputBmp); } else { MessageBox.Show("Could not import selected map"); return; } if (texSamplePicture.Image == null) { cb = new ColorBlend(); cb.Positions = new[] { 0, 1 / 3f, 1 / 2f, 3 / 4f, 7 / 8f, 1 }; cb.Colors = new[] { Color.FromArgb(61, 84, 51), Color.FromArgb(35, 50, 32), Color.FromArgb(35, 50, 32), Color.FromArgb(160, 153, 147), Color.FromArgb(247, 247, 251), Color.FromArgb(247, 247, 251) }; terrain.setTextureSample(cb); texSamplePicture.Image = terrain.getTextureSample(); } else { terrain.setTextureSample((Bitmap)texSamplePicture.Image); } colorMapPicture.Image = terrain.getTexture(); heightMapPicture.Image = terrain.getHeightBitmap(); } }