コード例 #1
0
ファイル: SmartTilesForm.cs プロジェクト: Grovespaz/MLLE
        private void CreateImageFromTileset()
        {
            //there are enough windows that show tileset images you'd think I should turn some/all of this into a method somewhere
            tilesetPicture.Height = (int)(Tileset.TotalNumberOfTiles + 9) / 10 * 32;
            var image = new Bitmap(tilesetPicture.Width, tilesetPicture.Height, System.Drawing.Imaging.PixelFormat.Format8bppIndexed);
            var data  = image.LockBits(new Rectangle(0, 0, image.Width, image.Height), ImageLockMode.WriteOnly, PixelFormat.Format8bppIndexed);

            byte[] bytes = new byte[data.Height * data.Stride];
            //Marshal.Copy(data.Scan0, bytes, 0, bytes.Length);
            for (uint i = 0; i < Tileset.TotalNumberOfTiles; ++i)
            {
                var tileImage = Tileset.Images[Tileset.ImageAddress[i]];
                var xOrg      = (i % 10) * 32;
                var yOrg      = i / 10 * 32;
                for (uint x = 0; x < 32; ++x)
                {
                    for (uint y = 0; y < 32; ++y)
                    {
                        bytes[xOrg + x + (yOrg + y) * data.Stride] = tileImage[x + y * 32];
                    }
                }
            }
            Marshal.Copy(bytes, 0, data.Scan0, bytes.Length);
            image.UnlockBits(data);

            var palette = new Palette();

            palette.CopyFrom(Tileset.Palette);
            palette.Colors[0] = Palette.Convert(TexturedJ2L.TranspColor);
            palette.Apply(image);

            ThreadSafeTilesetImage = (tilesetPicture.Image = image).Clone() as Image;
            smartPicture.Image     = Properties.Resources.SmartTilesPermutations;
            framesPicture.Image    = new Bitmap(32, 32);
        }
コード例 #2
0
        public static void Apply(this Palette pal, Bitmap bm)
        {
            var cpal = bm.Palette;

            pal.Apply(cpal);
            bm.Palette = cpal;
        }
コード例 #3
0
        public static Bitmap ToBitmap(this GraphicsBank tiles, Palette palette)
        {
            int widthTiles  = tiles.TilesX;
            int heightTiles = tiles.TilesY;

            var bm = new Bitmap(widthTiles * Tile.Width, heightTiles * Tile.Height, tiles.Format.AsPixelFormat());

            palette.Apply(bm);

            tiles.DrawInBitmap(bm);

            return(bm);
        }
コード例 #4
0
        public static Bitmap ToBitmap(this Tilemap tilemap, GraphicsBank tileSet, Palette palette)
        {
            int widthTiles  = tilemap.TilesX;
            int heightTiles = tilemap.TilesY;

            var bm = new Bitmap(widthTiles * Tile.Width, heightTiles * Tile.Height, PixelFormat.Format8bppIndexed);

            palette.Apply(bm);

            tilemap.DrawInBitmap(tileSet, bm);

            return(bm);
        }