public bool GetSubHeaderV2(int group, int image, out SFFSUBHEADERv2 header) { if ((mSubHeadersV2 == null) || (group < 0) || (image < 0)) { header = new SFFSUBHEADERv2(); return false; } if (mSubHeadersV2 != null) for (int i = 0; i < mSubHeadersV2.Count; ++i) { SFFSUBHEADERv2 sub = mSubHeadersV2[i]; int g = (int)sub.GroubNumber; int img = (int)sub.ImageNumber; if (g != group || img != image) continue; while (true) { if ((sub.subfileLength == 0) && (sub.IndexOfPrevious > 0) && (sub.IndexOfPrevious <= mSubHeadersV2.Count)) { sub = mSubHeadersV2[sub.IndexOfPrevious - 1]; } else break; } header = sub; return true; } header = new SFFSUBHEADERv2(); return false; }
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; }
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; }
public bool GetSubHeaderV2(int index, out SFFSUBHEADERv2 header) { if ((mSubHeadersV2 == null) || (index < 0) || (index >= mSubHeadersV2.Count)) { header = new SFFSUBHEADERv2(); return false; } header = mSubHeadersV2[index]; while (true) { if ((header.subfileLength == 0) && (header.IndexOfPrevious > 0) && (header.IndexOfPrevious < mSubHeadersV2.Count)) { header = mSubHeadersV2[header.IndexOfPrevious - 1]; } else break; } return true; }