public Stream GetFileStream(int tag, int level, int x, int y) { entry = new DirectoryEntry(tag, level, x, y, 0, 0); UInt32 index = entry.ComputeHash() % (UInt32)(header.HashBuckets); long hep = GetHashEntryPosition(index); DirectoryEntry de; while (hep != 0) { de = GetDirectoryEntry(hep); if ((de.x == x) && (de.y == y) && ((de.tag == tag) || (tag == -1)) && (de.level == level)) { return(StreamSlice.Create(dataStream, de.location, de.size)); } else { hep = de.NextEntryInChain; } } return(null); }
public static async Task <Stream> GetImageStreamAsync(Stream f, int level, int x, int y, CancellationToken token) { var offset = GetFileIndexOffset(level, x, y); f.Seek(offset, SeekOrigin.Begin); var(start, length) = await GetNodeInfoAsync(f, offset, token).ConfigureAwait(false); return(StreamSlice.Create(f, start, length)); }