void Parse(Stream s) { BinaryReader r = new BinaryReader(s); s.Position = 0; this.version = r.ReadUInt32(); this.doubledWidth = r.ReadUInt32(); this.height = r.ReadUInt32(); this.ageGender = (AgeGenderFlags)r.ReadUInt32(); this.physique = (Physiques)r.ReadByte(); this.shapeOrNormals = (ShapeOrNormals)r.ReadByte(); this.minCol = r.ReadUInt32(); this.maxCol = r.ReadUInt32(); this.minRow = r.ReadUInt32(); this.maxRow = r.ReadUInt32(); this.robeChannel = (RobeChannel)r.ReadByte(); int totalBytes = r.ReadInt32(); if (totalBytes == 0) { this.scanLines = new ScanLine[0]; } else { int width = (int)(maxCol - minCol + 1); uint numScanLines = maxRow - minRow + 1; this.scanLines = new ScanLine[numScanLines]; for (int i = 0; i < numScanLines; i++) { scanLines[i] = new ScanLine(recommendedApiVersion, OnResourceChanged, s, width); } } }
public ScanLine(int width, BinaryReader br) { this.width = width; this.scanLineDataSize = br.ReadUInt16(); this.isCompressed = (CompressionType)br.ReadByte(); if (this.isCompressed == CompressionType.NoData) { this.robeChannel = RobeChannel.ROBECHANNEL_DROPPED; } else { this.robeChannel = (RobeChannel)br.ReadByte(); } if (isCompressed == CompressionType.None) { if (robeChannel == RobeChannel.ROBECHANNEL_PRESENT) { this.uncompressedPixels = br.ReadBytes(width * 6); } else { this.uncompressedPixels = br.ReadBytes(width * 3); } } else if (isCompressed == CompressionType.RLE) { this.numIndexes = br.ReadByte(); this.pixelPosIndexes = new UInt16[numIndexes]; this.dataPosIndexes = new UInt16[numIndexes]; for (int i = 0; i < numIndexes; i++) { this.pixelPosIndexes[i] = br.ReadUInt16(); } for (int i = 0; i < numIndexes; i++) { this.dataPosIndexes[i] = br.ReadUInt16(); } uint headerdatasize = 4U + 1U + (4U * numIndexes); this.RLEArrayOfPixels = br.ReadBytes((int)(scanLineDataSize - headerdatasize)); } }
public void Parse(Stream s) { BinaryReader r = new BinaryReader(s); this.scanLineDataSize = r.ReadUInt16(); this.isCompressed = r.ReadBoolean(); this.robeChannel = (RobeChannel)r.ReadByte(); if (!isCompressed) { if (robeChannel == RobeChannel.ROBECHANNEL_PRESENT) { this.uncompressedPixels = r.ReadBytes(this.width * 6); } else { this.uncompressedPixels = r.ReadBytes(this.width * 3); } } else { this.numIndexes = r.ReadByte(); this.pixelPosIndexes = new UInt16[numIndexes]; this.dataPosIndexes = new UInt16[numIndexes]; for (int i = 0; i < numIndexes; i++) { this.pixelPosIndexes[i] = r.ReadUInt16(); } for (int i = 0; i < numIndexes; i++) { this.dataPosIndexes[i] = r.ReadUInt16(); } uint headerdatasize = 4U + 1U + (4U * numIndexes); this.rleArrayOfPixels = new byte[scanLineDataSize - headerdatasize]; for (int i = 0; i < rleArrayOfPixels.Length; i++) { this.rleArrayOfPixels[i] = r.ReadByte(); } } }