public void CreateNewTileset() { this.Show(); using (var fNew = new frmNew { }) if (DialogResult.OK == fNew.ShowDialog()) { PaletteFromImage = fNew.PaletteFromImage; PaletteFile = fNew.PaletteFile; ImageFile = fNew.ImageFile; TileSize = fNew.TileSize; srcfile = ImageFile; this.size = TileSize; surface1.TileSize = TileSize; Bitmap fbitmap = new Bitmap(ImageFile); Bitmap rbitmap = fbitmap.Clone(new Rectangle(0, 0, fbitmap.Width, fbitmap.Height), fbitmap.PixelFormat); if (!PaletteFromImage) { tpal = Palette.Load(PaletteFile, false); rbitmap.Palette = tpal.AsSystemPalette(); } surface1.Image = (Bitmap)rbitmap; surface1.Image.SetResolution(96, 96); // people keep being noobs about DPI, and GDI+ cares. surface1.TerrainTypes = new int[surface1.Image.Width / size, surface1.Image.Height / size]; /* all passable by default */ surface1.Templates = new List <Template>(); surface1.Size = surface1.Image.Size; surface1.Enabled = true; Load(); } }
public void CreateNewTileset() { this.Show(); using (var fNew = new frmNew { }) if (DialogResult.OK == fNew.ShowDialog()) { PaletteFromImage = fNew.PaletteFromImage; PaletteFile = fNew.PaletteFile; ImageFile = fNew.ImageFile; TileSize = fNew.TileSize; srcfile = ImageFile; this.size = TileSize; surface1.TileSize = TileSize; Bitmap fbitmap = new Bitmap(ImageFile); Bitmap rbitmap = fbitmap.Clone(new Rectangle(0, 0, fbitmap.Width, fbitmap.Height), fbitmap.PixelFormat); int[] ShadowIndex = { }; if (!PaletteFromImage) { tpal = Palette.Load(PaletteFile, ShadowIndex); rbitmap.Palette = tpal.AsSystemPalette(); } surface1.Image = (Bitmap)rbitmap; surface1.TilesPerRow = surface1.Image.Size.Width / surface1.TileSize; surface1.Image.SetResolution(96, 96); // people keep being noobs about DPI, and GDI+ cares. surface1.TerrainTypes = new int[surface1.Image.Width / size, surface1.Image.Height / size]; /* all passable by default */ surface1.Templates = new List<Template>(); surface1.Size = surface1.Image.Size; surface1.Enabled = true; Load(); } }