void CreateNewTileset() { Show(); using (var formNew = new FormNew()) if (DialogResult.OK == formNew.ShowDialog()) { srcfile = formNew.ImageFile; size = formNew.TileSize; var bitmap = new Bitmap(srcfile); if (!formNew.PaletteFromImage) { var terrainPalette = new ImmutablePalette(formNew.PaletteFile, new int[0]); ColorPalette pal; using (var b = new Bitmap(1, 1, PixelFormat.Format8bppIndexed)) pal = b.Palette; for (var i = 0; i < 256; i++) { pal.Entries[i] = Color.FromArgb(terrainPalette.GetColor(i).ToArgb()); } bitmap.Palette = pal; } InitializeSurface(bitmap); } }
void CreateNewTileset() { this.Show(); using (var formNew = new FormNew()) if (DialogResult.OK == formNew.ShowDialog()) { srcfile = formNew.ImageFile; this.size = formNew.TileSize; var bitmap = new Bitmap(srcfile); if (!formNew.PaletteFromImage) { var terrainPalette = new ImmutablePalette(formNew.PaletteFile, new int[0]); bitmap.Palette = terrainPalette.AsSystemPalette(); } InitializeSurface(bitmap); } }
public void CreateNewTileset() { this.Show(); using (var formNew = new FormNew { }) if (DialogResult.OK == formNew.ShowDialog()) { PaletteFromImage = formNew.PaletteFromImage; PaletteFile = formNew.PaletteFile; ImageFile = formNew.ImageFile; TileSize = formNew.TileSize; srcfile = ImageFile; this.size = TileSize; surface1.TileSize = TileSize; Bitmap rbitmap; using (var fbitmap = new Bitmap(ImageFile)) rbitmap = fbitmap.Clone(new Rectangle(0, 0, fbitmap.Width, fbitmap.Height), fbitmap.PixelFormat); int[] shadowIndex = { }; if (!PaletteFromImage) { TerrainPalette = new ImmutablePalette(PaletteFile, shadowIndex); rbitmap.Palette = TerrainPalette.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(); } }
public void CreateNewTileset() { this.Show(); using (var formNew = new FormNew { }) if (DialogResult.OK == formNew.ShowDialog()) { PaletteFromImage = formNew.PaletteFromImage; PaletteFile = formNew.PaletteFile; ImageFile = formNew.ImageFile; TileSize = formNew.TileSize; srcfile = ImageFile; this.size = TileSize; surface1.TileSize = TileSize; Bitmap rbitmap; using (var fbitmap = new Bitmap(ImageFile)) rbitmap = fbitmap.Clone(new Rectangle(0, 0, fbitmap.Width, fbitmap.Height), fbitmap.PixelFormat); int[] shadowIndex = { }; if (!PaletteFromImage) { TerrainPalette = new ImmutablePalette(PaletteFile, shadowIndex); rbitmap.Palette = TerrainPalette.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(); } }