コード例 #1
0
        private Image UpdateImage()
        {
            Image image;

            if (this.stopUpdating)
            {
                return(null);
            }
            if (this.tile.order != NCGR.TileOrder.NoTiled)
            {
                this.tile.rahc.nTilesX = (ushort)(this.numericWidth.Value / 8M);
                this.tile.rahc.nTilesY = (ushort)(this.numericHeight.Value / 8M);
            }
            else
            {
                this.tile.rahc.nTilesX = (ushort)this.numericWidth.Value;
                this.tile.rahc.nTilesY = (ushort)this.numericHeight.Value;
            }
            if (this.isMap)
            {
                NCGR.NCGR_s tile = this.tile;
                tile.rahc.tileData.tiles = Convertir.BytesToTiles(Convertir.TilesToBytes(tile.rahc.tileData.tiles, (int)this.tile.other));
                image = NCGR.Get_Image(tile, this.paleta, 0, this.trackZoom.Value);
            }
            else
            {
                image = NCGR.Get_Image(this.tile, this.paleta, (int)this.tile.other, this.trackZoom.Value);
            }
            this.pic.Image = image;
            return(image);
        }
コード例 #2
0
        public TileView(NCGR.NCGR_s tile, NCLR.NCLR_s paleta)
        {
            this.components = null;
            this.InitializeComponent();
            this.isMap  = false;
            this.paleta = paleta;
            this.tile   = tile;
            if (!(this.tile.other is int))
            {
                this.tile.other = 0;
            }
            this.pic.Image           = NCGR.Get_Image(tile, paleta, (int)this.tile.other);
            this.numericWidth.Value  = this.pic.Image.Width;
            this.numericHeight.Value = this.pic.Image.Height;
            this.comboDepth.Text     = (tile.rahc.depth == ColorDepth.Depth4Bit) ? "4 bpp" : "8 bpp";
            this.oldDepth            = this.comboDepth.Text;
            switch (tile.order)
            {
            case NCGR.TileOrder.NoTiled:
                this.oldTiles = 0;
                this.comboBox1.SelectedIndex = 0;
                break;

            case NCGR.TileOrder.Horizontal:
                this.oldTiles = 1;
                this.comboBox1.SelectedIndex = 1;
                break;
            }
            this.comboDepth.SelectedIndexChanged += new EventHandler(this.comboDepth_SelectedIndexChanged);
            this.numericWidth.ValueChanged       += new EventHandler(this.numericSize_ValueChanged);
            this.numericHeight.ValueChanged      += new EventHandler(this.numericSize_ValueChanged);
            this.numericStart.ValueChanged       += new EventHandler(this.numericStart_ValueChanged);
            this.Info();
            if ((new string(paleta.header.id) != "NCLR.NCLR_s") && (new string(paleta.header.id) != "RLCN"))
            {
                this.btnSetTrans.Enabled = false;
            }
        }
コード例 #3
0
    public static Bitmap Get_Image(Bank banco, uint blockSize, NCGR.NCGR_s tile, NCLR.NCLR_s paleta, bool entorno, bool celda, bool numero, bool transparencia, bool image, int maxWidth, int maxHeight, int zoom = 1)
    {
        int num;

        if (banco.cells.Length == 0)
        {
            return(new Bitmap(1, 1));
        }
        Size     size     = new Size(maxWidth * zoom, maxHeight * zoom);
        Bitmap   bitmap   = new Bitmap(size.Width, size.Height);
        Graphics graphics = Graphics.FromImage(bitmap);

        if (entorno)
        {
            for (num = -size.Width; num < size.Width; num += 8)
            {
                graphics.DrawLine(Pens.LightBlue, (num + (size.Width / 2)) * zoom, 0, (num + (size.Width / 2)) * zoom, size.Height * zoom);
                graphics.DrawLine(Pens.LightBlue, 0, (num + (size.Height / 2)) * zoom, size.Width * zoom, (num + (size.Height / 2)) * zoom);
            }
            graphics.DrawLine(Pens.Blue, (maxWidth / 2) * zoom, 0, (maxWidth / 2) * zoom, maxHeight * zoom);
            graphics.DrawLine(Pens.Blue, 0, (maxHeight / 2) * zoom, maxWidth * zoom, (maxHeight / 2) * zoom);
        }
        Image[] imageArray = new Image[banco.nCells];
        for (num = 0; num < banco.nCells; num++)
        {
            if ((banco.cells[num].width != 0) && (banco.cells[num].height != 0))
            {
                uint tileOffset = banco.cells[num].obj2.tileOffset;
                if (blockSize > 4)
                {
                    blockSize = 4;
                }
                if (tile.rahc.depth == ColorDepth.Depth4Bit)
                {
                    tileOffset = tileOffset << ((byte)blockSize);
                }
                else
                {
                    tileOffset = (tileOffset << ((byte)blockSize)) / 2;
                }
                if (image)
                {
                    for (int i = 0; i < tile.rahc.tileData.nPalette.Length; i++)
                    {
                        tile.rahc.tileData.nPalette[i] = banco.cells[num].obj2.index_palette;
                    }
                    if (blockSize < 4)
                    {
                        if (tile.order == NCGR.TileOrder.NoTiled)
                        {
                            imageArray[num] = NCGR.Get_Image(tile, paleta, (int)(tileOffset * 0x40), banco.cells[num].width, banco.cells[num].height, zoom);
                        }
                        else
                        {
                            imageArray[num] = NCGR.Get_Image(tile, paleta, (int)(tileOffset * 0x40), banco.cells[num].width / 8, banco.cells[num].height / 8, zoom);
                        }
                    }
                    else
                    {
                        tileOffset /= blockSize / 2;
                        int nTilesX = tile.rahc.nTilesX;
                        int nTilesY = tile.rahc.nTilesY;
                        if (tile.order == NCGR.TileOrder.Horizontal)
                        {
                            nTilesX *= 8;
                            nTilesY *= 8;
                        }
                        int num6 = (int)(((long)tileOffset) % ((long)nTilesX));
                        int num7 = (int)(((long)tileOffset) / ((long)nTilesX));
                        if (tile.rahc.depth == ColorDepth.Depth4Bit)
                        {
                            num7 = (int)(num7 * (blockSize * 2));
                        }
                        else
                        {
                            num7 = (int)(num7 * blockSize);
                        }
                        if (num7 >= nTilesY)
                        {
                            num7 = num7 % nTilesY;
                        }
                        imageArray[num] = NCGR.Get_Image(tile, paleta, zoom).Clone(new Rectangle(num6 * zoom, num7 * zoom, banco.cells[num].width * zoom, banco.cells[num].height * zoom), PixelFormat.Undefined);
                    }
                    if ((banco.cells[num].obj1.flipX == 1) && (banco.cells[num].obj1.flipY == 1))
                    {
                        imageArray[num].RotateFlip(RotateFlipType.Rotate180FlipNone);
                    }
                    else if (banco.cells[num].obj1.flipX == 1)
                    {
                        imageArray[num].RotateFlip(RotateFlipType.RotateNoneFlipX);
                    }
                    else if (banco.cells[num].obj1.flipY == 1)
                    {
                        imageArray[num].RotateFlip(RotateFlipType.Rotate180FlipX);
                    }
                    if (transparencia)
                    {
                        ((Bitmap)imageArray[num]).MakeTransparent(paleta.pltt.palettes[tile.rahc.tileData.nPalette[0]].colors[0]);
                    }
                    graphics.DrawImageUnscaled(imageArray[num], (size.Width / 2) + (banco.cells[num].obj1.xOffset * zoom), (size.Height / 2) + (banco.cells[num].obj0.yOffset * zoom));
                }
                if (celda)
                {
                    graphics.DrawRectangle(Pens.Black, (int)((size.Width / 2) + (banco.cells[num].obj1.xOffset * zoom)), (int)((size.Height / 2) + (banco.cells[num].obj0.yOffset * zoom)), (int)(banco.cells[num].width * zoom), (int)(banco.cells[num].height * zoom));
                }
                if (numero)
                {
                    graphics.DrawString(num.ToString(), SystemFonts.CaptionFont, Brushes.Black, (float)((size.Width / 2) + (banco.cells[num].obj1.xOffset * zoom)), (float)((size.Height / 2) + (banco.cells[num].obj0.yOffset * zoom)));
                }
            }
        }
        return(bitmap);
    }