private void btnExtract_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog o = new FolderBrowserDialog();

            o.Description         = "Select the folder to extract the images";
            o.ShowNewFolderButton = true;
            if (o.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            string folderOut = o.SelectedPath + Path.DirectorySeparatorChar;

            this.Cursor = Cursors.WaitCursor;
            BinaryReader br = new BinaryReader(File.OpenRead(gbcs));

            for (int i = 0; i < infos.Length; i++)
            {
                br.BaseStream.Position = infos[i].offset;

                char[]    header  = br.ReadChars(4);
                ushort    width   = br.ReadUInt16();
                ushort    height  = br.ReadUInt16();
                Color[][] palette = new Color[1][] { Actions.BGR555ToColor(br.ReadBytes(0x200)) };
                byte[]    tiles   = br.ReadBytes((int)(infos[i].size - 0x208));

                RawPalette pal = new RawPalette(palette, false, ColorFormat.colors256);
                RawImage   img = new RawImage(tiles, TileForm.Horizontal, ColorFormat.colors256, (int)width, (int)height, false);
                img.Get_Image(pal).Save(folderOut + "Image" + i.ToString() + ".png");
            }
            br.Close();
            this.Cursor = Cursors.Default;
        }
Exemple #2
0
        private void btnExtract_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog o = new FolderBrowserDialog();

            o.Description         = "Select the folder to save the sprites.";
            o.ShowNewFolderButton = true;
            if (o.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            this.Cursor = Cursors.WaitCursor;
            string folderOut = o.SelectedPath + Path.DirectorySeparatorChar;

            for (int i = 0; i < imgs.Length; i++)
            {
                if (palettes[i] == null)
                {
                    palettes[i] = Save_File(palettes_[i]);
                }

                BinaryReader br = new BinaryReader(File.OpenRead(palettes[i]));
                br.BaseStream.Position = 0x3340;
                Color[][] pal = new Color[1][] { Actions.BGR555ToColor(br.ReadBytes(0x40)) };
                br.Close();

                palette = new RawPalette(pal, false, ColorFormat.colors16);

                if (imgs[i] == null)
                {
                    imgs[i] = Save_File(imgs_[i]);
                }

                uint max_imgs = (uint)(new FileInfo(imgs[i]).Length / 0x200);


                br = new BinaryReader(File.OpenRead(imgs[i]));
                for (int j = 0; j < max_imgs; j++)
                {
                    br.BaseStream.Position = j * 0x200;
                    byte[] tiles = br.ReadBytes(0x200);

                    ImageBase image = new RawImage(tiles, TileForm.Lineal, ColorFormat.colors16, 0x20, 0x20, false);
                    image.Get_Image(palette).Save(folderOut + "Sprite" + i.ToString() + '_' + j.ToString() + ".png");
                }
                br.Close();
            }
            this.Cursor = Cursors.Default;
        }