Пример #1
0
        // Token: 0x06000008 RID: 8 RVA: 0x00002634 File Offset: 0x00000834
        private void button_Import_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Title  = "Open";
            openFileDialog.Filter = "PNG (*.png)|*.png";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                Bitmap bitmap = new Bitmap(openFileDialog.FileName);
                if (this.bm.Width == bitmap.Width && this.bm.Height == bitmap.Height)
                {
                    if (this.GetColorCount(bitmap) <= Program.ColorCount)
                    {
                        this.BTXFile           = BTX0.Write(this.BTXFile, bitmap);
                        this.bm                = BTX0.Read(this.BTXFile);
                        this.pictureBox1.Image = this.bm;
                        return;
                    }
                    MessageBox.Show(string.Concat(new object[]
                    {
                        "Too many colors!\nBTX: ",
                        Program.ColorCount,
                        "\nPNG: ",
                        this.GetColorCount(bitmap)
                    }), "Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    return;
                }
                else
                {
                    MessageBox.Show(string.Concat(new object[]
                    {
                        "Not the same size!\nBTX: ",
                        this.bm.Width,
                        "x",
                        this.bm.Height,
                        "\nPNG: ",
                        bitmap.Width,
                        "x",
                        bitmap.Height
                    }), "Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
        }
Пример #2
0
        // Token: 0x06000004 RID: 4 RVA: 0x0000246B File Offset: 0x0000066B
        public Form1(string[] args)
        {
            String pngFile;

            if (args.Length != 2)
            {
                Console.WriteLine("pngtobtx0 reimports png images into a template btx0 file.\nin this repository, it is used with the template btx0's in rawdata specifically.\nspecifically made for hgss' a081 narc and for usage with hgss-monexpansion.\nUsage:  pngtobtx0 [png file] [btx0 file]");
            }

            try
            {
                this.BTXFile = File.ReadAllBytes("rawdata\\a081_smallmon");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);

                return;
            }

            this.bm = BTX0.Read(this.BTXFile);
            if (this.bm == null)
            {
                Console.WriteLine("target file specified is not a btx0 file");
            }

            if (Program.PaletteSize == 64U && Program.PaletteCount == 2U)             // handle shiny palette if one exists first
            {
                Program.PaletteIndex = 1U;
                pngFile = args[0];
                if (pngFile.Contains(".png"))
                {
                    pngFile = pngFile.Substring(0, pngFile.Length - ".png".Length);
                }

                Bitmap shinymap = new Bitmap(pngFile + "_shiny.png");

                if (pngFile.Contains("graphics\\overworlds\\"))
                {
                    pngFile = pngFile.Substring("graphics\\overworlds\\".Length, pngFile.Length - "graphics\\overworlds\\".Length);
                }

                if (shinymap.Width > 32)                 // if a big mon
                {
                    try
                    {
                        this.BTXFile = File.ReadAllBytes("rawdata\\a081_bigmon");
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);

                        return;
                    }

                    this.bm = BTX0.Read(this.BTXFile);
                }

                if (this.bm.Width == shinymap.Width && this.bm.Height == shinymap.Height)
                {
                    if (this.GetColorCount(shinymap) <= Program.ColorCount)
                    {
                        this.BTXFile = BTX0.Write(this.BTXFile, shinymap);

                        File.WriteAllBytes(args[1], this.BTXFile);
                    }
                    else
                    {
                        Console.WriteLine("shiny palette has too many colors");
                        return;
                    }
                }
                else
                {
                    Console.WriteLine("shiny png isn't the right width or height");
                    return;
                }
            }

            pngFile = args[0];
            if (pngFile.Contains(".png"))
            {
                pngFile = pngFile.Substring(0, pngFile.Length - ".png".Length);
            }

            Program.PaletteIndex = 0U;

            Bitmap bitmap = new Bitmap(pngFile + ".png");

            if (pngFile.Contains("graphics\\overworlds\\"))
            {
                pngFile = pngFile.Substring("graphics\\overworlds\\".Length, pngFile.Length - "graphics\\overworlds\\".Length);
            }

            if (bitmap.Width > 32)             // if a big mon
            {
                try
                {
                    this.BTXFile = File.ReadAllBytes("rawdata\\a081_bigmon");
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);

                    return;
                }

                this.bm = BTX0.Read(this.BTXFile);
            }

            if (this.bm.Width == bitmap.Width && this.bm.Height == bitmap.Height)
            {
                if (this.GetColorCount(bitmap) <= Program.ColorCount)
                {
                    this.BTXFile = BTX0.Write(this.BTXFile, bitmap);

                    File.WriteAllBytes(args[1], this.BTXFile);
                }
                else
                {
                    Console.WriteLine("normal palette has too many colors");
                    return;
                }
            }
            else
            {
                Console.WriteLine("png file doesn't have the right width or height");
                return;
            }
        }