コード例 #1
0
        public Image Get_Image(ImageBase image, PaletteBase palette)
        {
            if (image.FormTile == TileForm.Lineal)
            {
                image.FormTile = TileForm.Horizontal;
            }

            Byte[] tiles, tile_pal;
            NTFS[] currMap = (NTFS[])map.Clone();
            tiles = Actions.Apply_Map(currMap, image.Tiles, out tile_pal, image.BPP, image.TileSize);

            ImageBase newImage = new TestImage();

            newImage.Set_Tiles(tiles, image.Width, image.Height, image.FormatColor, image.FormTile, image.CanEdit, image.TileSize);
            newImage.TilesPalette = tile_pal;
            newImage.Zoom         = image.Zoom;

            if (height != 0)
            {
                newImage.Height = height;
            }
            if (width != 0)
            {
                newImage.Width = width;
            }

            return(newImage.Get_Image(palette));
        }
コード例 #2
0
ファイル: Actions.cs プロジェクト: MetLob/tinke
        public static Bitmap Get_Image(Bank bank, uint blockSize, ImageBase img, PaletteBase pal, int max_width, int max_height,
            bool draw_grid, bool draw_cells, bool draw_numbers, bool trans, bool image, int currOAM = -1,
            int zoom = 1, int[] index = null)
        {
            Size size = new Size(max_width * zoom, max_height * zoom);
            Bitmap bank_img = new Bitmap(size.Width, size.Height);
            Graphics graphic = Graphics.FromImage(bank_img);

            if (bank.oams.Length == 0)
            {
                graphic.DrawString("No OAM", SystemFonts.CaptionFont, Brushes.Black, new PointF(max_width / 2, max_height / 2));
                return bank_img;
            }

            if (draw_grid)
            {
                for (int i = (0 - size.Width); i < size.Width; i += 8)
                {
                    graphic.DrawLine(Pens.LightBlue, (i + size.Width / 2) * zoom, 0, (i + size.Width / 2) * zoom, size.Height * zoom);
                    graphic.DrawLine(Pens.LightBlue, 0, (i + size.Height / 2) * zoom, size.Width * zoom, (i + size.Height / 2) * zoom);
                }
                graphic.DrawLine(Pens.Blue, (max_width / 2) * zoom, 0, (max_width / 2) * zoom, max_height * zoom);
                graphic.DrawLine(Pens.Blue, 0, (max_height / 2) * zoom, max_width * zoom, (max_height / 2) * zoom);
            }

            Image cell;
            for (int i = 0; i < bank.oams.Length; i++)
            {
                bool draw = false;
                if (index == null)
                    draw = true;
                else
                    for (int k = 0; k < index.Length; k++)
                        if (index[k] == i)
                            draw = true;
                if (!draw)
                    continue;

                if (bank.oams[i].width == 0x00 || bank.oams[i].height == 0x00)
                    continue;

                uint tileOffset = bank.oams[i].obj2.tileOffset;
                tileOffset = (uint)(tileOffset << (byte)blockSize);

                if (image)
                {
                    ImageBase cell_img = new TestImage();
                    cell_img.Set_Tiles((byte[])img.Tiles.Clone(), bank.oams[i].width, bank.oams[i].height, img.FormatColor,
                                       img.FormTile, false);
                    cell_img.StartByte = (int)(tileOffset * 0x20 + bank.data_offset);

                    byte num_pal = bank.oams[i].obj2.index_palette;
                    if (num_pal >= pal.NumberOfPalettes)
                        num_pal = 0;
                    for (int j = 0; j < cell_img.TilesPalette.Length; j++)
                        cell_img.TilesPalette[j] = num_pal;

                    cell = cell_img.Get_Image(pal);
                    //else
                    //{
                    //    tileOffset /= (blockSize / 2);
                    //    int imageWidth = img.Width;
                    //    int imageHeight = img.Height;

                    //    int posX = (int)(tileOffset % imageWidth);
                    //    int posY = (int)(tileOffset / imageWidth);

                    //    if (img.ColorFormat == ColorFormat.colors16)
                    //        posY *= (int)blockSize * 2;
                    //    else
                    //        posY *= (int)blockSize;
                    //    if (posY >= imageHeight)
                    //        posY = posY % imageHeight;

                    //    cells[i] = ((Bitmap)img.Get_Image(pal)).Clone(new Rectangle(posX * zoom, posY * zoom, bank.oams[i].width * zoom, bank.oams[i].height * zoom),
                    //                                                System.Drawing.Imaging.PixelFormat.DontCare);
                    //}

                    #region Flip
                    if (bank.oams[i].obj1.flipX == 1 && bank.oams[i].obj1.flipY == 1)
                        cell.RotateFlip(RotateFlipType.RotateNoneFlipXY);
                    else if (bank.oams[i].obj1.flipX == 1)
                        cell.RotateFlip(RotateFlipType.RotateNoneFlipX);
                    else if (bank.oams[i].obj1.flipY == 1)
                        cell.RotateFlip(RotateFlipType.RotateNoneFlipY);
                    #endregion

                    if (trans)
                        ((Bitmap)cell).MakeTransparent(pal.Palette[num_pal][0]);

                    graphic.DrawImageUnscaled(cell, size.Width / 2 + bank.oams[i].obj1.xOffset * zoom, size.Height / 2 + bank.oams[i].obj0.yOffset * zoom);
                }

                if (draw_cells)
                    graphic.DrawRectangle(Pens.Black, size.Width / 2 + bank.oams[i].obj1.xOffset * zoom, size.Height / 2 + bank.oams[i].obj0.yOffset * zoom,
                        bank.oams[i].width * zoom, bank.oams[i].height * zoom);
                if (i == currOAM)
                    graphic.DrawRectangle(new Pen(Color.Red, 3), size.Width / 2 + bank.oams[i].obj1.xOffset * zoom, size.Height / 2 + bank.oams[i].obj0.yOffset * zoom,
                        bank.oams[i].width * zoom, bank.oams[i].height * zoom);
                if (draw_numbers)
                    graphic.DrawString(bank.oams[i].num_cell.ToString(), SystemFonts.CaptionFont, Brushes.Black, size.Width / 2 + bank.oams[i].obj1.xOffset * zoom,
                        size.Height / 2 + bank.oams[i].obj0.yOffset * zoom);
            }

            return bank_img;
        }
コード例 #3
0
ファイル: MapBase.cs プロジェクト: ShadeDBZ/tinke
        public Image Get_Image(ImageBase image, PaletteBase palette)
        {
            if (image.FormTile == TileForm.Lineal)
                image.FormTile = TileForm.Horizontal;

            Byte[] tiles, tile_pal;
            NTFS[] currMap = (NTFS[])map.Clone();
            tiles = Actions.Apply_Map(currMap, image.Tiles, out tile_pal, image.BPP, image.TileSize);

            ImageBase newImage = new TestImage();
            newImage.Set_Tiles(tiles, image.Width, image.Height, image.FormatColor, image.FormTile, image.CanEdit, image.TileSize);
            newImage.TilesPalette = tile_pal;
            newImage.Zoom = image.Zoom;

            if (height != 0)
                newImage.Height = height;
            if (width != 0)
                newImage.Width = width;

            return newImage.Get_Image(palette);
        }