public static void DecompressFileToHDD(int pntr)
 {
     if (File.Exists(RomHandler.tmpDir + pntr.ToString("x")))
     {
         return;
     }
     try
     {
         byte[]       byteArray    = RomHandler.DecompressFileToByteArray(pntr);
         FileStream   fileStream   = File.Create(RomHandler.tmpDir + pntr.ToString("x"));
         BinaryWriter binaryWriter = new BinaryWriter((Stream)fileStream);
         try
         {
             binaryWriter.Write(byteArray);
             binaryWriter.Close();
             fileStream.Close();
         }
         catch
         {
             binaryWriter.Close();
             fileStream.Close();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #2
0
        private void ShowSelectedSprite()
        {
            int index1 = 0;

            while (index1 < this.newSprite_flp.Controls.Count)
            {
                this.newSprite_flp.Controls[index1].Dispose();
            }
            this.newSprite = (List <Bitmap>)null;
            try
            {
                int index2 = 0;
                while (index2 < this.sprite_flp.Controls.Count)
                {
                    this.sprite_flp.Controls[index2].Dispose();
                }
                int index3 = (int)this.sprites_dgv.SelectedRows[0].Cells[0].Value;
                this.selectedSprite = this.sprites[index3];
                if (this.selectedSprite.compressed)
                {
                    RomHandler.DecompressFileToHDD(this.sprites[index3].pointer);
                    if (File.Exists(RomHandler.tmpDir + this.sprites[index3].pointer.ToString("x")))
                    {
                        byte[] file = File.ReadAllBytes(RomHandler.tmpDir + this.sprites[index3].pointer.ToString("x"));
                        if (this.sprites[index3].frames.Count == 0)
                        {
                            ImageHandler.ConvertSprite(ref file, this.sprites[index3]);
                        }
                    }
                }
                else
                {
                    byte[] decompressedFile = RomHandler.GetDecompressedFile(this.selectedSprite.pointer, 20480);
                    if (this.sprites[index3].frames.Count == 0)
                    {
                        ImageHandler.ConvertSprite(ref decompressedFile, this.sprites[index3]);
                    }
                }
                foreach (Bitmap frame in this.selectedSprite.frames)
                {
                    PictureBox pictureBox = new PictureBox();
                    pictureBox.Width  = frame.Width;
                    pictureBox.Height = frame.Height;
                    pictureBox.Image  = (Image)frame;
                    this.sprite_flp.Controls.Add((Control)pictureBox);
                }
                this.lbl_frameCount.Text = this.selectedSprite.frames.Count <Bitmap>().ToString();
                this.lbl_type.Text       = Enum.GetName(typeof(SpriteTextureFormat), (object)this.selectedSprite.textureFormat) ?? "UNK";
            }
            catch
            {
            }
        }
        public static byte[] DecompressFileToByteArray(int pntr)
        {
            int num1           = (int)RomHandler.rom[pntr] * 16777216 + (int)RomHandler.rom[pntr + 1] * 65536 + (int)RomHandler.rom[pntr + 2] * 256 + (int)RomHandler.rom[pntr + 3];
            int compressedSize = RomHandler.getNextPointer(pntr) - num1;
            int num2           = num1 + 68816;

            byte[] numArray = new byte[compressedSize];
            for (int index = 0; index < compressedSize; ++index)
            {
                numArray[index] = RomHandler.rom[num2 + index];
            }
            GECompression geCompression = new GECompression();

            byte[] Buffer = numArray;
            geCompression.SetCompressedBuffer(Buffer, Buffer.Length);
            int fileSize = 0;

            return(geCompression.OutputDecompressedBuffer(ref fileSize, ref compressedSize));
        }