public void ExportData() { Config config = this.GetConfig(); Export export = new Export(); export.width.Maximum = this.heightData.Width; export.width.Value = this.heightData.Width; export.height.Maximum = this.heightData.Height; export.height.Value = this.heightData.Height; if (config.exportRescaleMode) { export.subzeroMode2.Checked = true; } if (export.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (this.FileDialog(this.exportHeightmapDialog, ref config.lastExportedFile)) { string path = this.exportHeightmapDialog.FileName; string ext = path.Substring(path.LastIndexOf('.'), path.Length - path.LastIndexOf('.')).ToLower(); //config.lastExportedFile = path; config.exportRescaleMode = export.subzeroMode2.Checked; HeightData toExport = Main.GetResizedHeightData(this.heightData, (int)export.width.Value, (int)export.height.Value); // rescale the values if necessary if (ext != ".shd" && export.subzeroMode2.Checked) { Main.ScaleHeightValues(ref toExport, 0, short.MaxValue - 1); } if (ext == ".shd") { System.IO.BinaryWriter writer = new System.IO.BinaryWriter(System.IO.File.Open(path, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write)); writer.Write(toExport.Width); writer.Write(toExport.Height); for (int i = 0; i < toExport.Length; i++) { writer.Write(toExport[i]); } writer.Close(); } else { Main.HeightDataToBitmap(toExport).Save(path); } toExport.Dispose(); } } }