本文整理汇总了C#中IImageStream.ReadCompressedUInt32方法的典型用法代码示例。如果您正苦于以下问题:C# IImageStream.ReadCompressedUInt32方法的具体用法?C# IImageStream.ReadCompressedUInt32怎么用?C# IImageStream.ReadCompressedUInt32使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IImageStream
的用法示例。
在下文中一共展示了IImageStream.ReadCompressedUInt32方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Populate
void Populate(IImageStream reader) {
var chars = new char[0x200];
reader.Position = 1;
while (reader.Position < reader.Length) {
uint offset = (uint)reader.Position;
uint len;
if (!reader.ReadCompressedUInt32(out len)) {
if (offset == reader.Position)
reader.Position++;
continue;
}
if (len == 0 || reader.Position + len > reader.Length)
continue;
int stringLen = (int)len / 2;
if (stringLen > chars.Length)
Array.Resize(ref chars, stringLen);
for (int i = 0; i < stringLen; i++)
chars[i] = (char)reader.ReadUInt16();
if ((len & 1) != 0)
reader.ReadByte();
var s = new string(chars, 0, stringLen);
if (!cachedDict.ContainsKey(s))
cachedDict[s] = offset;
}
}
示例2: GetReader_NoLock
int GetReader_NoLock(uint offset, out IImageStream reader) {
reader = null;
if (!IsValidOffset(offset))
return -1;
reader = GetReader_NoLock(offset);
uint length;
if (!reader.ReadCompressedUInt32(out length))
return -1;
if (reader.Position + length < length || reader.Position + length > reader.Length)
return -1;
return (int)length; // length <= 0x1FFFFFFF so this cast does not make it negative
}
示例3: Populate
void Populate(IImageStream reader) {
reader.Position = 1;
while (reader.Position < reader.Length) {
uint offset = (uint)reader.Position;
uint len;
if (!reader.ReadCompressedUInt32(out len)) {
if (offset == reader.Position)
reader.Position++;
continue;
}
if (len == 0 || reader.Position + len > reader.Length)
continue;
var data = reader.ReadBytes((int)len);
if (!cachedDict.ContainsKey(data))
cachedDict[data] = offset;
}
}