Ejemplo n.º 1
0
		public static SFFHEADERv2 LoadFromStream(Stream stream)
		{
			SFFHEADERv2 ret = new SFFHEADERv2 ();
			if (stream == null)
				return ret;
			var mgr = FilePathMgr.GetInstance ();

			ret.signature = mgr.ReadString (stream, 12, System.Text.Encoding.UTF8);
			ret.verhi = (byte)stream.ReadByte ();
			ret.verlo = (byte)stream.ReadByte ();
			ret.verhi2 = (byte)stream.ReadByte ();
			ret.verlo2 = (byte)stream.ReadByte ();
			ret.reserved1 = (uint)mgr.ReadInt (stream);
			ret.reserved2 = (uint)mgr.ReadInt (stream);
			ret.compatverlo3 = (byte)stream.ReadByte ();
			ret.compatverlo1 = (byte)stream.ReadByte ();
			ret.compatverlo2 = (byte)stream.ReadByte ();
			ret.compatverhi = (byte)stream.ReadByte ();
			ret.reserved3 = (uint)mgr.ReadInt (stream);
			ret.reserved4 = (uint)mgr.ReadInt (stream);
			ret.offsetSubFile = (uint)mgr.ReadInt (stream);
			ret.totalImage = (uint)mgr.ReadInt (stream);
			ret.offsetPaletteFile = (uint)mgr.ReadInt (stream);
			ret.totalPalette = (uint)mgr.ReadInt (stream);
			ret.offsetLData = (uint)mgr.ReadInt (stream);
			ret.sizeLData = (uint)mgr.ReadInt (stream);
			ret.offsetTData = (uint)mgr.ReadInt (stream);
			ret.sizeTData = (uint)mgr.ReadInt (stream);
			ret.reserved5 = (uint)mgr.ReadInt (stream);
			ret.reserved6 = (uint)mgr.ReadInt (stream);
			ret.comments = mgr.ReadString (stream, 436, System.Text.Encoding.UTF8);

			return ret;
		}
Ejemplo n.º 2
0
		public static PCXHEADER LoadFromStream(Stream stream)
		{
			PCXHEADER header = new PCXHEADER ();
			if (stream == null) {
				return header;
			}
			var mgr = FilePathMgr.GetInstance ();
			header.Manufacturer = (byte)stream.ReadByte ();
			header.Version = (byte)stream.ReadByte ();
			header.Encoding = (byte)stream.ReadByte ();
			header.BPP = (byte)stream.ReadByte ();
			header.x = (ushort)mgr.ReadShort (stream);
			header.y = (ushort)mgr.ReadShort (stream);
			header.widht = (ushort)mgr.ReadShort (stream);
			header.height = (ushort)mgr.ReadShort (stream);
			header.HRES = (ushort)mgr.ReadShort (stream);
			header.VRES = (ushort)mgr.ReadShort (stream);
			header.ColorMap = mgr.ReadString (stream, 48, System.Text.Encoding.ASCII);
			header.reserved1 = (byte)stream.ReadByte ();
			header.NPlanes = (byte)stream.ReadByte ();
			header.bytesPerLine = (byte)stream.ReadByte ();
			header.palletInfo = (byte)stream.ReadByte ();
			header.HorzScreenSize = (ushort)mgr.ReadShort (stream);
			header.VertScreenSize = (ushort)mgr.ReadShort (stream);
			header.Reserved2 = mgr.ReadString(stream, 54, System.Text.Encoding.ASCII);
			return header;
		}
Ejemplo n.º 3
0
        public override int GetHashCode()
        {
            int ret = FilePathMgr.InitHashValue();

            FilePathMgr.HashCode(ref ret, fileName);
            FilePathMgr.HashCode(ref ret, resType);
            return(ret);
        }
Ejemplo n.º 4
0
        public override int GetHashCode()
        {
            int ret = FilePathMgr.InitHashValue();

            FilePathMgr.HashCode(ref ret, usePlatform);
            FilePathMgr.HashCode(ref ret, isUseABCreateFromFile);
            return(ret);
        }
Ejemplo n.º 5
0
        public override int GetHashCode()
        {
            int ret = FilePathMgr.InitHashValue();

            FilePathMgr.HashCode(ref ret, fontName);
            FilePathMgr.HashCode(ref ret, faceIndex);
            return(ret);
        }
Ejemplo n.º 6
0
        protected override string ReadKey(Stream stream)
        {
            if (stream == null)
            {
                return(default(string));
            }
            string key = FilePathMgr.GetInstance().ReadString(stream);

            return(key);
        }
Ejemplo n.º 7
0
        public override int GetHashCode()
        {
            int ret = FilePathMgr.InitHashValue();

            FilePathMgr.HashCode(ref ret, value);
            FilePathMgr.HashCode(ref ret, fontSize);
            FilePathMgr.HashCode(ref ret, fontSizeType);
            FilePathMgr.HashCode(ref ret, hDpi);
            FilePathMgr.HashCode(ref ret, vDpi);
            return(ret);
        }
Ejemplo n.º 8
0
        private void LoadObjectIndex(ConfigFileHeader header, Stream stream)
        {
            var map = this.IndexDataMap;

            for (int i = 0; i < header.Count; ++i)
            {
                K             key    = ReadKey(stream);
                long          offset = FilePathMgr.GetInstance().ReadLong(stream);
                int           index  = FilePathMgr.GetInstance().ReadInt(stream);
                IndexFileData data   = new IndexFileData();
                data.Index          = index;
                data.Offset         = offset;
                data.Count          = 1;
                m_IndexDataMap[key] = data;
            }
        }
Ejemplo n.º 9
0
        public static SFFSUBHEADER LoadFromStream(Stream stream)
        {
            var mgr = FilePathMgr.GetInstance();
            SFFSUBHEADER subHeader = new SFFSUBHEADER();
            
            subHeader.NextSubheaderFileOffset = (uint)mgr.ReadInt(stream);
            subHeader.LenghtOfSubheader = (uint)mgr.ReadInt(stream);
            subHeader.x = mgr.ReadShort(stream);
            subHeader.y = mgr.ReadShort(stream);
            subHeader.GroubNumber = mgr.ReadShort(stream);
            subHeader.ImageNumber = mgr.ReadShort(stream);
            subHeader.IndexOfPrevious = mgr.ReadShort(stream);
            subHeader.PalletSame = mgr.ReadBool(stream);
            subHeader.BALNK = mgr.ReadString(stream, 13, System.Text.Encoding.ASCII);

            return subHeader;
        }
Ejemplo n.º 10
0
		private bool LoadSubFilesV2(SFFHEADERv2 header, Stream stream)
		{
			if (stream == null || header.offsetSubFile == 0)
				return false;
			int offset = (int)header.offsetSubFile;
			if (offset < 0 || offset >= stream.Length)
				return false;
			int cnt = (int)header.totalImage;
			if (cnt < 0)
				return false;

			if (stream.Seek (offset, SeekOrigin.Begin) != offset)
				return false;
			var filePathMgr = FilePathMgr.GetInstance ();
			for (int i = 0; i < cnt; ++i) {
				SFFSUBHEADERv2 subHeader = SFFSUBHEADERv2.LoadFromStream (stream);
				SubHeadersV2.Add (subHeader);
			}

			if (mSubHeadersV2 != null) {
				for (int i = 0; i < mSubHeadersV2.Count; ++i) {
					var subHeader = mSubHeadersV2 [i];
					KeyValuePair<uint, uint> key = new KeyValuePair<uint, uint> ((uint)subHeader.GroubNumber, (uint)subHeader.ImageNumber);
					if (mPcxDataMap.ContainsKey (key))
						continue;
					// 读取pcx
					if (subHeader.subfileLength == 0 && subHeader.IndexOfPrevious != 0) {
						// LINK模式
					} else {
						if (subHeader.subfileLength == 0)
							continue;
						int off = (int)subHeader.offsetData;
						if (off > 0) {
							stream.Seek (off, SeekOrigin.Begin);

							byte[] buffer = new byte[subHeader.subfileLength];
							stream.Read (buffer, 0, buffer.Length);
							buffer = DeCompressBuffer (buffer, (PcxCompressType)subHeader.fmt);
						}
					}
				}
			}
			return true;
		}
Ejemplo n.º 11
0
 private void LoadMapIndex(ConfigFileHeader header, Stream stream)
 {
     for (int i = 0; i < header.Count; ++i)
     {
         K             key    = ReadKey(stream);
         long          offset = FilePathMgr.GetInstance().ReadLong(stream);
         int           cnt    = FilePathMgr.GetInstance().ReadInt(stream);
         int           index  = FilePathMgr.GetInstance().ReadInt(stream);
         IndexFileData data   = new IndexFileData();
         data.Index  = index;
         data.Offset = offset;
         data.Count  = cnt;
         if (m_IndexDataMap == null)
         {
             m_IndexDataMap = new Dictionary <K, IndexFileData>();
         }
         m_IndexDataMap[key] = data;
     }
 }
Ejemplo n.º 12
0
		public static SFFSUBHEADERv2 LoadFromStream(Stream stream)
		{
			SFFSUBHEADERv2 subHeader = new SFFSUBHEADERv2 ();
			if (stream == null)
				return subHeader;
			var filePathMgr = FilePathMgr.GetInstance ();
			subHeader.GroubNumber = filePathMgr.ReadShort(stream);
			subHeader.ImageNumber = filePathMgr.ReadShort(stream);
			subHeader.width = filePathMgr.ReadShort(stream);
			subHeader.height = filePathMgr.ReadShort(stream);
			subHeader.x = filePathMgr.ReadShort(stream);
			subHeader.y = filePathMgr.ReadShort(stream);
			subHeader.IndexOfPrevious = filePathMgr.ReadShort(stream);
			subHeader.fmt = (byte)stream.ReadByte();
			subHeader.coldepth = (byte)stream.ReadByte();
			subHeader.offsetData = (uint)filePathMgr.ReadInt(stream);
			subHeader.subfileLength = (uint)filePathMgr.ReadInt(stream);
			subHeader.palletteIndex = filePathMgr.ReadShort(stream);
			subHeader.flags = filePathMgr.ReadShort(stream);
			return subHeader;
		}
Ejemplo n.º 13
0
        private bool LoadDataFromStream(Stream stream)
        {
            if (m_IndexFile == null || stream == null || !stream.CanRead)
            {
                return(false);
            }
            long cntOffset = stream.Length - 4;

            if (cntOffset <= 0)
            {
                return(false);
            }
            stream.Seek(cntOffset, SeekOrigin.Begin);
            int cnt = FilePathMgr.GetInstance().ReadInt(stream);

            if (cnt <= 0)
            {
                return(false);
            }

            ConfigWrap.ConfigValueType valueType = this.ValueType;
            System.Type tt = typeof(K);
            stream.Seek(0, SeekOrigin.Begin);
            // int startIndex = FilePathMgr.GetInstance().ReadInt(stream);
            for (int i = 0; i < cnt; ++i)
            {
                System.Object key   = FilePathMgr.GetInstance().ReadObject(stream, tt);
                K             k     = (K)key;
                V             value = ReadItemValue(stream, k);
                if (m_DataMap == null)
                {
                    m_DataMap = new Dictionary <K, V>();
                }
                m_DataMap[k] = value;
            }
            return(true);
        }
Ejemplo n.º 14
0
 protected virtual K ReadKey(Stream stream)
 {
     System.Object value = FilePathMgr.GetInstance().ReadObject(stream, typeof(K));
     return((K)value);
 }