Example #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);
        }
Example #2
0
    public static byte[][] Change_ImageCell(Cell cell, uint blockSize, NCGR.NCGR_s newTiles, NCGR.NCGR_s oldImage)
    {
        uint          num3;
        int           num4;
        List <byte[]> list       = new List <byte[]>();
        List <byte[]> collection = new List <byte[]>();
        List <byte>   list3      = new List <byte>();

        for (int i = 0; i < 0x200; i++)
        {
            for (int j = 0; j < 0x200; j++)
            {
                if (((i >= (0x100 + cell.obj0.yOffset)) && (i < ((0x100 + cell.obj0.yOffset) + cell.height))) && ((j >= (0x100 + cell.obj1.xOffset)) && (j < ((0x100 + cell.obj1.xOffset) + cell.width))))
                {
                    list3.Add(newTiles.rahc.tileData.tiles[0][j + (i * 0x200)]);
                }
            }
        }
        if (oldImage.order == NCGR.TileOrder.Horizontal)
        {
            collection.AddRange(Convertir.BytesToTiles_NoChanged(list3.ToArray(), cell.width / 8, cell.height / 8));
        }
        else
        {
            collection.Add(list3.ToArray());
        }
        list3.Clear();
        if (oldImage.order == NCGR.TileOrder.Horizontal)
        {
            num3  = (oldImage.rahc.depth == ColorDepth.Depth4Bit) ? (cell.obj2.tileOffset * 2) : cell.obj2.tileOffset;
            num3 *= (blockSize != 0) ? blockSize : 1;
            for (num4 = 0; num4 < num3; num4++)
            {
                list.Add(oldImage.rahc.tileData.tiles[num4]);
            }
            list.AddRange(collection);
            for (num4 = ((int)num3) + ((cell.width * cell.height) / 0x40); num4 < oldImage.rahc.tileData.tiles.Length; num4++)
            {
                list.Add(oldImage.rahc.tileData.tiles[num4]);
            }
        }
        else if (oldImage.order == NCGR.TileOrder.NoTiled)
        {
            num3  = ((oldImage.rahc.depth == ColorDepth.Depth4Bit) ? (cell.obj2.tileOffset * 2) : cell.obj2.tileOffset) * 0x40;
            num3 *= (blockSize != 0) ? blockSize : 1;
            for (num4 = 0; num4 < num3; num4++)
            {
                list3.Add(oldImage.rahc.tileData.tiles[0][num4]);
            }
            list3.AddRange(collection[0]);
            for (num4 = ((int)num3) + (cell.width * cell.height); num4 < oldImage.rahc.tileData.tiles[0].Length; num4++)
            {
                list3.Add(oldImage.rahc.tileData.tiles[0][num4]);
            }
            list.Add(list3.ToArray());
        }
        return(list.ToArray());
    }
Example #3
0
        public TileView(NCGR.NCGR_s tile, NCLR.NCLR_s paleta, NSCR.NSCR_s map)
        {
            this.components = null;
            this.InitializeComponent();
            this.isMap  = true;
            this.paleta = paleta;
            this.tile   = tile;
            this.map    = map;
            if (!(this.tile.other is int))
            {
                this.tile.other = 0;
            }
            if (!(this.map.other is int))
            {
                this.map.other = 0;
            }
            this.numericWidth.Value  = map.section.width;
            this.numericHeight.Value = map.section.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;
            }
            this.UpdateImage();
        }
Example #4
0
    public static byte[][] Change_ColorCell(Cell cell, uint blockSize, NCGR.NCGR_s image, int oldIndex, int newIndex)
    {
        uint          num;
        int           num2;
        List <byte[]> list  = new List <byte[]>();
        List <byte>   list2 = new List <byte>();

        if (image.order == NCGR.TileOrder.Horizontal)
        {
            num  = (image.rahc.depth == ColorDepth.Depth4Bit) ? (cell.obj2.tileOffset * 2) : cell.obj2.tileOffset;
            num *= (blockSize != 0) ? blockSize : 1;
            for (num2 = 0; num2 < image.rahc.tileData.tiles.Length; num2++)
            {
                if ((num2 >= num) && (num2 < (((int)num) + ((cell.width * cell.height) / 0x40))))
                {
                    byte[] item = new byte[0x40];
                    for (int i = 0; i < 0x40; i++)
                    {
                        if (image.rahc.tileData.tiles[num2][i] == oldIndex)
                        {
                            item[i] = (byte)newIndex;
                        }
                        else if (image.rahc.tileData.tiles[num2][i] == newIndex)
                        {
                            item[i] = (byte)oldIndex;
                        }
                        else
                        {
                            item[i] = image.rahc.tileData.tiles[num2][i];
                        }
                    }
                    list.Add(item);
                }
                else
                {
                    list.Add(image.rahc.tileData.tiles[num2]);
                }
            }
        }
        else if (image.order == NCGR.TileOrder.NoTiled)
        {
            num  = ((image.rahc.depth == ColorDepth.Depth4Bit) ? (cell.obj2.tileOffset * 2) : cell.obj2.tileOffset) * 0x40;
            num *= (blockSize != 0) ? blockSize : 1;
            for (num2 = 0; num2 < image.rahc.tileData.tiles[0].Length; num2++)
            {
                if ((num2 >= num) && (num2 < (((int)num) + (cell.width * cell.height))))
                {
                    if (image.rahc.tileData.tiles[0][num2] == oldIndex)
                    {
                        list2.Add((byte)newIndex);
                    }
                    else if (image.rahc.tileData.tiles[0][num2] == newIndex)
                    {
                        list2.Add((byte)oldIndex);
                    }
                    else
                    {
                        list2.Add(image.rahc.tileData.tiles[0][num2]);
                    }
                }
                else
                {
                    list2.Add(image.rahc.tileData.tiles[0][num2]);
                }
            }
            list.Add(list2.ToArray());
        }
        return(list.ToArray());
    }
Example #5
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);
    }