Beispiel #1
0
        public static void ReadFile(string FileName)
        {
            ASCIIEncoding asciiEncoding = new ASCIIEncoding();
            FileStream    fileStream    = new FileStream(FileName, FileMode.Open);
            BinaryReader  b             = new BinaryReader((Stream)fileStream);

            Tex.lcTex        = new tTexture();
            Tex.lcTex.Header = new tHeader();
            Tex.lcTex.Header.VersionChunk = b.ReadBytes(4);
            Tex.lcTex.Header.Version      = b.ReadInt32();
            Tex.lcTex.Header.DataChunk    = b.ReadBytes(4);
            Tex.lcTex.Header.Width        = b.ReadUInt32() ^ 303316286U;
            Tex.lcTex.Header.Shift        = b.ReadUInt32() ^ 1431797889U;
            Tex.lcTex.Header.Height       = b.ReadUInt32() ^ 2560279492U;
            Tex.lcTex.Header.MipMap       = b.ReadUInt32() ^ 3688695303U;
            Tex.lcTex.Header.Bits         = b.ReadUInt32() ^ 505432394U;
            Tex.lcTex.Header.Unknown      = b.ReadUInt32() ^ 1633913997U;
            Tex.lcTex.Header.Format       = asciiEncoding.GetString(b.ReadBytes(4));
            Tex.lcTex.Header.AnimOffset   = b.ReadInt32();
            Tex.lcTex.Header.Width        = Tex.Shift(Tex.lcTex.Header.Width, Tex.lcTex.Header.Shift);
            Tex.lcTex.Header.Height       = Tex.Shift(Tex.lcTex.Header.Height, Tex.lcTex.Header.Shift);
            if (Tex.lcTex.Header.Format == "FRMC")
            {
                Tex.ReadFRMC(Tex.lcTex, b);
            }
            else if (Tex.lcTex.Header.Format == "FRMS")
            {
                Tex.ReadFRMS(Tex.lcTex, b);
            }
            fileStream.Close();
        }
Beispiel #2
0
 private static void ReadFRMC(tTexture lcTex, BinaryReader b)
 {
     lcTex.imageData = new byte[(int)lcTex.Header.MipMap][];
     for (int index = 0; (long)index < (long)lcTex.Header.MipMap; ++index)
     {
         lcTex.imageData[index] = b.ReadBytes(b.ReadInt32());
     }
 }
Beispiel #3
0
        private static void ReadFRMS(tTexture lcTex, BinaryReader b)
        {
            int num   = (int)lcTex.Header.Width * (int)lcTex.Header.Height;
            int count = (int)lcTex.Header.Bits == 0 || (int)lcTex.Header.Bits == 2 ? num * 3 : num * 4;

            lcTex.imageData = new byte[(int)lcTex.Header.MipMap][];
            for (int index = 0; (long)index < (long)lcTex.Header.MipMap; ++index)
            {
                lcTex.imageData[index] = b.ReadBytes(count);
            }
        }