Esempio n. 1
0
    public static Bitmap Get_Image(NCGR_s tile, NCLR.NCLR_s paleta, int zoom = 1)
    {
        if (tile.rahc.nTilesX == 0xffff)
        {
            if (tile.order == TileOrder.NoTiled)
            {
                tile.rahc.nTilesX = 0x40;
            }
            else
            {
                tile.rahc.nTilesX = 8;
            }
        }
        if (tile.rahc.nTilesY == 0xffff)
        {
            if (tile.order == TileOrder.NoTiled)
            {
                if (tile.rahc.nTiles >= 0x40)
                {
                    tile.rahc.nTilesY = (ushort)((tile.rahc.nTiles / 0x40) * 0x40);
                }
                else
                {
                    tile.rahc.nTilesY = 0x40;
                }
            }
            else if (tile.rahc.nTiles >= 0x40)
            {
                tile.rahc.nTilesY = (ushort)(tile.rahc.nTiles / 8);
            }
            else
            {
                tile.rahc.nTilesY = 8;
            }
        }
        switch (tile.order)
        {
        case TileOrder.NoTiled:
            return(No_Tile(tile, paleta, 0, tile.rahc.nTilesX, tile.rahc.nTilesY, zoom));

        case TileOrder.Horizontal:
            return(Horizontal(tile, paleta, 0, tile.rahc.nTilesX, tile.rahc.nTilesY, zoom));

        case TileOrder.Vertical:
            throw new NotImplementedException();
        }
        return(new Bitmap(0, 0));
    }
Esempio n. 2
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();
        }
Esempio n. 3
0
    private static Bitmap Horizontal(NCGR_s tile, NCLR.NCLR_s paleta, int startTile, int tilesX, int tilesY, int zoom = 1)
    {
        if (zoom <= 0)
        {
            zoom = 1;
        }
        Bitmap bitmap = new Bitmap((tilesX * 8) * zoom, (tilesY * 8) * zoom);

        tile.rahc.tileData.tiles = Convertir.BytesToTiles(Convertir.TilesToBytes(tile.rahc.tileData.tiles, startTile));
        startTile = 0;
        for (int i = 0; i < tilesY; i++)
        {
            for (int j = 0; j < tilesX; j++)
            {
                for (int k = 0; k < 8; k++)
                {
                    for (int m = 0; m < 8; m++)
                    {
                        for (int n = 0; n < zoom; n++)
                        {
                            for (int num6 = 0; num6 < zoom; num6++)
                            {
                                try
                                {
                                    if (tile.rahc.tileData.tiles[j + (i * tilesX)].Length == 0)
                                    {
                                        return(bitmap);
                                    }
                                    bitmap.SetPixel(((m + (j * 8)) * zoom) + num6, ((k + (i * 8)) * zoom) + n, paleta.pltt.palettes[tile.rahc.tileData.nPalette[startTile]].colors[tile.rahc.tileData.tiles[startTile][m + (k * 8)]]);
                                }
                                catch
                                {
                                    return(bitmap);
                                }
                            }
                        }
                    }
                }
                startTile++;
            }
        }
        return(bitmap);
    }
Esempio n. 4
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);
    }