示例#1
0
        // NEEDS TO BE MOVED TO THE FORMS SIDE
        public static void GetAndDrawTrainerPic(this PictureBox picBox, int index)
        {
            var sOffset   = int.Parse(Ini.GetString(Conversions.ToString(MMainFunctions.GetIniFileLocation()), MainObject.Header, "TrainerImageTable", ""), System.Globalization.NumberStyles.HexNumber) + index * 8;
            var pOffset   = int.Parse(Ini.GetString(Conversions.ToString(MMainFunctions.GetIniFileLocation()), MainObject.Header, "TrainerPaletteTable", ""), System.Globalization.NumberStyles.HexNumber) + index * 8;
            var temp      = new byte[4096];
            var image     = new byte[65536];
            var palette15 = new byte[4096];

            Color[] palette32;
            Bitmap  bSprite;

            using (var fs = new FileStream(MainObject.LoadedRom, FileMode.Open, FileAccess.Read))
            {
                using var r = new BinaryReader(fs);
                fs.Position = sOffset;
                sOffset     = r.ReadInt32() - 0x8000000;
                fs.Position = sOffset;
                r.Read(temp, 0, 0xFFF);
                Lz77.Lz77UnComp(temp, image);
                temp        = new byte[4096];
                fs.Position = pOffset;
                pOffset     = r.ReadInt32() - 0x8000000;
                fs.Position = pOffset;
                r.Read(temp, 0, 0xFFF);
                Lz77.Lz77UnComp(temp, palette15);
                palette32 = GetImageFunctions.LoadPalette(palette15);
            }

            bSprite      = GetImageFunctions.LoadSprite(ref image, palette32, 64, 64, Conversions.ToBoolean(Ini.GetString(MainObject.AppPath + "GBAPGESettings.ini", "Settings", "TransparentImages", "0")));
            picBox.Image = bSprite;
            picBox.Refresh();
        }
示例#2
0
        public static void GetAndDrawFrontPokemonPicBlack(this PictureBox picBox, int index)
        {
            var sOffset = int.Parse(Ini.GetString(Conversions.ToString(MMainFunctions.GetIniFileLocation()), MainObject.Header, "PokemonFrontSprites", ""), System.Globalization.NumberStyles.HexNumber) + index * 8; // Pointer to Pokemon front sprites, + 8 = Bulbasaur.
            var pOffset = int.Parse(Ini.GetString(Conversions.ToString(MMainFunctions.GetIniFileLocation()), MainObject.Header, "PokemonNormalPal", ""), System.Globalization.NumberStyles.HexNumber) + index * 8;    // Pointer to Pokemon normal palettes, + 8 = Bulbasaur.


            var temp      = new byte[4096];
            var image     = new byte[65536];
            var palette15 = new byte[4096];


            Color[] palette32;
            Bitmap  bSprite;


            using (var fileStream = new FileStream(MainObject.LoadedRom, FileMode.Open, FileAccess.Read))
            {
                using var r         = new BinaryReader(fileStream);
                fileStream.Position = sOffset;
                sOffset             = r.ReadInt32() - 0x8000000;
                fileStream.Position = sOffset;
                r.Read(temp, 0, 0xFFF);
                Lz77.Lz77UnComp(temp, image);
                temp = new byte[4096];
                fileStream.Position = pOffset;
                pOffset             = r.ReadInt32() - 0x8000000;
                fileStream.Position = pOffset;
                r.Read(temp, 0, 0xFFF);
                Lz77.Lz77UnComp(temp, palette15);
                palette32     = GetImageFunctions.LoadPalette(palette15);
                palette32[1]  = Color.Black;
                palette32[2]  = Color.Black;
                palette32[3]  = Color.Black;
                palette32[4]  = Color.Black;
                palette32[5]  = Color.Black;
                palette32[6]  = Color.Black;
                palette32[7]  = Color.Black;
                palette32[8]  = Color.Black;
                palette32[9]  = Color.Black;
                palette32[10] = Color.Black;
                palette32[11] = Color.Black;
                palette32[12] = Color.Black;
                palette32[13] = Color.Black;
                palette32[14] = Color.Black;
                palette32[15] = Color.Black;
            }

            bSprite      = GetImageFunctions.LoadSprite(ref image, palette32, 64, 64, Conversions.ToBoolean(Ini.GetString(MainObject.AppPath + "GBAPGESettings.ini", "Settings", "TransparentImages", "0")));
            picBox.Image = bSprite;
            picBox.Refresh();
        }