コード例 #1
0
        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);
                }
        }
コード例 #2
0
        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);
                }
        }
コード例 #3
0
        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);
                }
        }
コード例 #4
0
        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();
                }
        }
コード例 #5
0
ファイル: FormBuilder.cs プロジェクト: Berzeger/OpenRA
		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();
				}
		}