/// <summary> /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see> /// </summary> public override void ReadData(byte version, BufferedBinaryReader binaryReader) { RecordHeader rh = new RecordHeader(); rh.ReadData(binaryReader); fontId = binaryReader.ReadUInt16(); byte fontNameLen = binaryReader.ReadByte(); fontName = binaryReader.ReadString(fontNameLen); binaryReader.ReadUBits(2); //reserved fontFlagsSmallText = binaryReader.ReadBoolean(); binaryReader.ReadUBits(2); //not used fontFlagsItalic = binaryReader.ReadBoolean(); fontFlagsBold = binaryReader.ReadBoolean(); binaryReader.ReadBoolean(); //not used languageCode = binaryReader.ReadByte(); long codeTableLenght = rh.TagLength - 5 - fontNameLen; codeTable = null; codeTable = new ushort[codeTableLenght]; for (int i = 0; i < codeTableLenght / 2; i++) { codeTable[i] = binaryReader.ReadUInt16(); } }
/// <summary> /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see> /// </summary> public override void ReadData(byte version, BufferedBinaryReader binaryReader) { RecordHeader rh = new RecordHeader(); rh.ReadData(binaryReader); characterId = binaryReader.ReadUInt16(); depth = binaryReader.ReadUInt16(); }
/// <summary> /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see> /// </summary> public override void ReadData(byte version, BufferedBinaryReader binaryReader) { RecordHeader rh = new RecordHeader(); rh.ReadData(binaryReader); recursion = binaryReader.ReadUInt16(); timeout = binaryReader.ReadUInt16(); }
/// <summary> /// Reads the data. /// </summary> /// <param name="binaryReader">Binary reader.</param> public void ReadData(BufferedBinaryReader binaryReader) { startWith = binaryReader.ReadUInt16(); endWith = binaryReader.ReadUInt16(); startColor = new RGBA(); startColor.ReadData(binaryReader); endColor = new RGBA(); endColor.ReadData(binaryReader); }
public void Load(BufferedBinaryReader reader) { if (reader.Length < 128) { throw new BadImageFormatException(); } // - DOSHeader // PE 2 // Start 58 // Lfanew 4 // End 64 if (reader.ReadUInt16() != 0x5a4d) { throw new BadImageFormatException(); } reader.Advance(58); reader.Position = reader.ReadUInt32(); // PE NT signature if (reader.ReadUInt32() != 0x00004550) { throw new BadImageFormatException(); } // - PEFileHeader Architecture = ReadArchitecture(reader); // 2 bytes ushort numberOfSections = reader.ReadUInt16(); // TimeDateStamp 4 // PointerToSymbolTable 4 // NumberOfSymbols 4 // OptionalHeaderSize 2 reader.Advance(14); // Characteristics 2 ushort characteristics = reader.ReadUInt16(); DataDirectory cli; ushort subsystem, dll_characteristics; ReadOptionalHeaders(reader, out subsystem, out dll_characteristics, out cli); Kind = ResolveModuleKind(characteristics, subsystem); Characteristics = (ModuleCharacteristics)dll_characteristics; ReadSections(reader, numberOfSections); ReadCliHeader(reader, cli); }
/// <summary> /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see> /// </summary> public override void ReadData(byte version, BufferedBinaryReader binaryReader) { RecordHeader rh = new RecordHeader(); rh.ReadData(binaryReader); characterId = binaryReader.ReadUInt16(); numFrames = binaryReader.ReadUInt16(); width = binaryReader.ReadUInt16(); height = binaryReader.ReadUInt16(); binaryReader.ReadUBits(5); videoFlagsDeblocking = binaryReader.ReadUBits(2); videoFlagsSmoothing = binaryReader.ReadBoolean(); codecId = binaryReader.ReadByte(); }
/// <summary> /// Reads the data. /// </summary> /// <param name="binaryReader">Binary reader.</param> /// <param name="fontFlagsWideCodes">Font flags wide codes.</param> public void ReadData(BufferedBinaryReader binaryReader, bool fontFlagsWideCodes) { this.fontFlagsWideCodes = fontFlagsWideCodes; if (fontFlagsWideCodes) { fontFlagsWideCode1 = (uint)binaryReader.ReadUInt16(); fontFlagsWideCode2 = (uint)binaryReader.ReadUInt16(); } else { fontFlagsWideCode1 = (uint)binaryReader.ReadByte(); fontFlagsWideCode2 = (uint)binaryReader.ReadByte(); } short fontKerningAdjustement = binaryReader.ReadInt16(); }
/// <summary> /// Reads the data from a binary file /// </summary> /// <param name="binaryReader">Binary reader.</param> public void ReadData(BufferedBinaryReader binaryReader) { ushort tagCL = binaryReader.ReadUInt16(); tagCode = Convert.ToUInt16(tagCL >> 6); tagLength = System.Convert.ToUInt32(tagCL - (tagCode << 6)); bool longTag; if (tagLength == 0x3F) { uint len = binaryReader.ReadUInt32(); tagLength = len; longTag = (tagLength <= 127); } else { longTag = false; } if (tagLength > binaryReader.BaseStream.Length) { throw new InvalidTagLengthException(); } }
/// <summary> /// Reads the data. /// </summary> /// <param name="binaryReader">Binary reader.</param> public void ReadData(BufferedBinaryReader binaryReader) { uint count = 0; byte fillStyleCount = binaryReader.ReadByte(); count = fillStyleCount; ushort fillStyleCountExtended = 0; if (fillStyleCount == 0xFF) { fillStyleCountExtended = binaryReader.ReadUInt16(); count = fillStyleCountExtended; } if (count > 0) { for (int i = 0; i < count; i++) { byte fillStyleType = binaryReader.PeekByte(); MorphFillStyle morphFillStyle = GetMorphFillStyleFromType(fillStyleType); if (morphFillStyle != null) { morphFillStyle.ReadData(binaryReader); this.Add(morphFillStyle); } } } }
internal static GridDefinitionSection BuildFrom(BufferedBinaryReader reader) { var currentPosition = reader.Position; var length = reader.ReadUInt32(); var section = reader.ReadUInt8(); // This is section 3 if (section != (int)SectionCode.GridDefinitionSection) { throw new UnexpectedGribSectionException(SectionCode.GridDefinitionSection, section); } var source = reader.ReadUInt8(); var numberPoints = reader.ReadUInt32(); var olLength = reader.ReadUInt8(); var olInterpretation = reader.ReadUInt8(); var templateNumber = reader.ReadUInt16(); var gridDefinition = GridDefinitionFactories.Build(reader, templateNumber); // Prevent from over-reading the stream reader.Seek(currentPosition + length, SeekOrigin.Begin); return(new GridDefinitionSection(length, section, source, numberPoints, olLength, olInterpretation, templateNumber, gridDefinition)); }
private void LoadPSPFile(Stream input) { byte[] sigBytes = new byte[32]; input.ProperRead(sigBytes, 0, sigBytes.Length); if (!CheckSig(sigBytes)) { throw new FormatException(Properties.Resources.InvalidPSPFile); } using (BufferedBinaryReader reader = new BufferedBinaryReader(input)) { this.fileHeader = new FileHeader(reader); while (reader.Position < reader.Length) { uint blockSig = reader.ReadUInt32(); if (blockSig != PSPConstants.blockIdentifier) { throw new FormatException(Properties.Resources.InvalidBlockSignature); } PSPBlockID blockID = (PSPBlockID)reader.ReadUInt16(); uint initialBlockLength = this.fileHeader.Major <= PSPConstants.majorVersion5 ? reader.ReadUInt32() : 0; uint blockLength = reader.ReadUInt32(); switch (blockID) { case PSPBlockID.ImageAttributes: this.imageAttributes = new GeneralImageAttributes(reader, this.fileHeader.Major); break; case PSPBlockID.Creator: this.creator = new CreatorBlock(reader, blockLength); break; case PSPBlockID.ColorPalette: this.globalPalette = new ColorPaletteBlock(reader, this.fileHeader.Major); break; case PSPBlockID.LayerStart: this.layerBlock = new LayerBlock(reader, this.imageAttributes, this.fileHeader.Major); break; case PSPBlockID.ExtendedData: this.extData = new ExtendedDataBlock(reader, blockLength); break; #if DEBUG case PSPBlockID.CompositeImageBank: this.compImage = new CompositeImageBlock(reader, this.fileHeader.Major); break; #endif default: reader.Position += blockLength; break; } } } }
/// <summary> /// Reads the data. /// </summary> /// <param name="binaryReader">Binary reader.</param> /// <param name="shapeType">Shape type.</param> public void ReadData(BufferedBinaryReader binaryReader, ShapeType shapeType) { int count = 0; byte fillStyleCount = binaryReader.ReadByte(); count = System.Convert.ToInt32(fillStyleCount); ushort fillStyleCountExtended = 0; if (fillStyleCount == 0xFF && (shapeType == ShapeType.Shape2 || shapeType == ShapeType.Shape3)) { fillStyleCountExtended = binaryReader.ReadUInt16(); count = System.Convert.ToInt32(fillStyleCountExtended); } if (count != 0) { for (int i = 0; i < count; i++) { byte fillStyleType = binaryReader.PeekByte(); FillStyle fillStyle = GetFillStyleFromType(fillStyleType); if (fillStyle != null) { fillStyle.ReadData(binaryReader, shapeType); this.Add(fillStyle); } } } }
public static EncodedTranscriptData Read(BufferedBinaryReader reader) { var info = reader.ReadUInt16(); var contents = reader.ReadByte(); return(new EncodedTranscriptData(info, contents)); }
private void readInstruments(BufferedBinaryReader source, int nbInstruments) { uint instrumentHeaderSize; ushort nbSamples; IList <UInt32> sampleSizes = new List <uint>(); for (int i = 0; i < nbInstruments; i++) { Instrument instrument = new Instrument(); instrumentHeaderSize = source.ReadUInt32(); instrument.DisplayName = Utils.Latin1Encoding.GetString(source.ReadBytes(22)).Trim(); instrument.DisplayName = instrument.DisplayName.Replace("\0", ""); source.Seek(1, SeekOrigin.Current); // Instrument type; useless according to documentation nbSamples = source.ReadUInt16(); source.Seek(instrumentHeaderSize - 29, SeekOrigin.Current); if (nbSamples > 0) { sampleSizes.Clear(); for (int j = 0; j < nbSamples; j++) // Sample headers { sampleSizes.Add(source.ReadUInt32()); source.Seek(36, SeekOrigin.Current); } for (int j = 0; j < nbSamples; j++) // Sample data { source.Seek(sampleSizes[j], SeekOrigin.Current); } } FInstruments.Add(instrument); } }
/// <summary> /// Reads the data. /// </summary> /// <param name="binaryReader">Binary reader.</param> public void ReadData(BufferedBinaryReader binaryReader) { uint count = 0; byte lineStyleCount = binaryReader.ReadByte(); count = lineStyleCount; ushort lineStyleCountExtended = 0; if (lineStyleCount == 0xFF) { lineStyleCountExtended = binaryReader.ReadUInt16(); count = lineStyleCountExtended; } if (count > 0) { for (int i = 0; i < count; i++) { MorphLineStyle morphLineStyle = new MorphLineStyle(); morphLineStyle.ReadData(binaryReader); this.Add(morphLineStyle); } } }
/// <summary> /// Reads the data. /// </summary> /// <param name="binaryReader">Binary reader.</param> /// <param name="numGlyphs">Num glyphs.</param> public void ReadData(BufferedBinaryReader binaryReader, ushort numGlyphs) { if (numGlyphs == 0) { return; } ShapeWithStyle.NumFillBits = 0; ShapeWithStyle.NumLineBits = 0; ShapeRecordCollection[] shapes = new ShapeRecordCollection[numGlyphs]; for (int i = 0; i < numGlyphs; i++) { ShapeRecordCollection glyphShape = new ShapeRecordCollection(); glyphShape.ReadData(binaryReader, ShapeType.None); shapes[i] = glyphShape; } for (int i = 0; i < numGlyphs; i++) { char c; if (isWideCodes) { c = (char)binaryReader.ReadUInt16(); } else { c = (char)binaryReader.ReadByte(); } this[c] = shapes[i]; } shapes = null; }
/// <summary> /// Reads the data. /// </summary> /// <param name="binaryReader">Binary reader.</param> /// <param name="shapeType">Shape type.</param> public void ReadData(BufferedBinaryReader binaryReader, ShapeType shapeType) { int count = 0; byte lineStyleCount = binaryReader.ReadByte(); count = System.Convert.ToInt32(lineStyleCount); ushort lineStyleCountExtended = 0; if (lineStyleCount == 0xFF) { lineStyleCountExtended = binaryReader.ReadUInt16(); count = System.Convert.ToInt32(lineStyleCountExtended); } if (count > 0) { for (int i = 0; i < count; i++) { LineStyle lineStyle = new LineStyle(); lineStyle.ReadData(binaryReader, shapeType); Add(lineStyle); } } }
/// <summary> /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see> /// </summary> public override void ReadData(byte version, BufferedBinaryReader binaryReader) { RecordHeader rh = new RecordHeader(); rh.ReadData(binaryReader); int tl = System.Convert.ToInt32(rh.TagLength); int count = binaryReader.ReadUInt16(); for (int i = 0; i < count; i++) { int id = binaryReader.ReadUInt16(); string name = binaryReader.ReadString(Encoding.UTF8); tagsData.Add(id, name); } }
internal static DataRepresentationSection BuildFrom(BufferedBinaryReader reader) { var sectionStartPosition = reader.Position; // octets 1-4 (Length of DRS) var length = reader.ReadUInt32(); var section = reader.ReadUInt8(); if (section != (int)SectionCode.DataRepresentationSection) { throw new UnexpectedGribSectionException( SectionCode.DataRepresentationSection, section ); } var dataPoints = reader.ReadUInt32(); var dataTemplateNumber = reader.ReadUInt16(); var dataRepresentation = DataRepresentationFactory.Build(reader, dataTemplateNumber); // Prevent from over-reading the stream reader.Seek(sectionStartPosition + length, SeekOrigin.Begin); return(new DataRepresentationSection(length, section, dataPoints, dataTemplateNumber, dataRepresentation)); }
internal static IdentificationSection BuildFrom(BufferedBinaryReader reader) { // section 1 octet 1-4 (length of section) var length = reader.ReadUInt32(); var section = reader.ReadUInt8(); if (section != (int)SectionCode.IdentificationSection) { return(null); } // Center octet 6-7 var centerCode = reader.ReadUInt16(); // Center octet 8-9 var subCenterCode = reader.ReadUInt16(); // Parameter master table octet 10 var masterTableVersion = reader.ReadUInt8(); // Parameter local table octet 11 var localTableVersion = reader.ReadUInt8(); // significanceOfRT octet 12 var significanceOfRt = reader.ReadUInt8(); // octets 13-19 (base time of forecast) var refTime = reader.ReadDateTime(); var productStatusCode = reader.ReadUInt8(); var productTypeCode = reader.ReadUInt8(); return(new IdentificationSection( length, section, centerCode, subCenterCode, masterTableVersion, localTableVersion, significanceOfRt, refTime, productStatusCode, productTypeCode)); }
private static object ReadValue(BufferedBinaryReader reader, SystemTypeCode type) { switch (type) { case SystemTypeCode.Boolean: return(reader.ReadBoolean()); case SystemTypeCode.Int8: return(reader.ReadInt8()); case SystemTypeCode.UInt8: return(reader.ReadUInt8()); case SystemTypeCode.Int16: return(reader.ReadInt16()); case SystemTypeCode.UInt16: return(reader.ReadUInt16()); case SystemTypeCode.Int32: return(reader.ReadInt32()); case SystemTypeCode.UInt32: return(reader.ReadUInt32()); case SystemTypeCode.Int64: return(reader.ReadInt64()); case SystemTypeCode.UInt64: return(reader.ReadUInt64()); case SystemTypeCode.Single: return(reader.ReadSingle()); case SystemTypeCode.Double: return(reader.ReadDouble()); case SystemTypeCode.Decimal: throw new NotImplementedException(); case SystemTypeCode.DateTime: throw new NotImplementedException(); case SystemTypeCode.Char: return(reader.ReadChar()); case SystemTypeCode.String: return(reader.ReadCountedUtf8()); case SystemTypeCode.Enum: throw new NotImplementedException(); default: throw new ArgumentOutOfRangeException(); } }
/// <summary> /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see> /// </summary> public override void ReadData(byte version, BufferedBinaryReader binaryReader) { RecordHeader rh = new RecordHeader(); rh.ReadData(binaryReader); shapeId = binaryReader.ReadUInt16(); rect.ReadData(binaryReader); shape.ReadData(binaryReader, this.shapeType); }
/// <summary> /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see> /// </summary> public override void ReadData(byte version, BufferedBinaryReader binaryReader) { RecordHeader rh = new RecordHeader(); rh.ReadData(binaryReader); buttonId = binaryReader.ReadUInt16(); buttonColorTransform = new CXForm(); buttonColorTransform.ReadData(binaryReader); }
private static TargetArchitecture ReadArchitecture(BufferedBinaryReader reader) { var target = (TargetArchitecture)reader.ReadUInt16(); if (!Enum.IsDefined(typeof(TargetArchitecture), target)) { throw new NotSupportedException(); } return(target); }
/// <summary> /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see> /// </summary> public override void ReadData(byte version, BufferedBinaryReader binaryReader) { RecordHeader rh = new RecordHeader(); rh.ReadData(binaryReader); soundId = binaryReader.ReadUInt16(); soundInfo = new SoundInfo(); soundInfo.ReadData(binaryReader); }
/// <summary> /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see> /// </summary> public override void ReadData(byte version, BufferedBinaryReader binaryReader) { RecordHeader rh = new RecordHeader(); rh.ReadData(binaryReader); // inner tags long endPos = binaryReader.BaseStream.Position + rh.TagLength; // stuff before inner tags, just read it and dont look any further spriteId = binaryReader.ReadUInt16(); frameCount = binaryReader.ReadUInt16(); while (binaryReader.BaseStream.Position < endPos) { BaseTag b = SwfReader.ReadTag(version, binaryReader, this.tagList); this.tagList.Add(b); } }
/// <summary> /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see> /// </summary> public override void ReadData(byte version, BufferedBinaryReader binaryReader) { RecordHeader rh = new RecordHeader(); rh.ReadData(binaryReader); spriteId = binaryReader.ReadUInt16(); int lenght = System.Convert.ToInt32(rh.TagLength - 2); actionRecord = binaryReader.ReadBytes(lenght); }
/// <summary> /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see> /// </summary> public override void ReadData(byte version, BufferedBinaryReader binaryReader) { RecordHeader rh = new RecordHeader(); rh.ReadData(binaryReader); streamId = binaryReader.ReadUInt16(); frameNum = binaryReader.ReadUInt16(); if (codecId == 2) { video = new H263VideoPacket(); video.ReadData(binaryReader); } else if (codecId == 3) { video = new ScreenVideoPacket(); video.ReadData(binaryReader); } }
/// <summary> /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see> /// </summary> public override void ReadData(byte version, BufferedBinaryReader binaryReader) { RecordHeader rh = new RecordHeader(); rh.ReadData(binaryReader); int tl = System.Convert.ToInt32(rh.TagLength); characterId = binaryReader.ReadUInt16(); jpegData = binaryReader.ReadBytes(tl - 2); }
public ThumbnailBlock(BufferedBinaryReader br) { this.width = br.ReadInt32(); this.height = br.ReadInt32(); this.bitDepth = br.ReadUInt16(); this.compressionType = (PSPCompression)br.ReadUInt16(); this.planeCount = br.ReadUInt16(); this.colorCount = br.ReadUInt32(); this.paletteEntryCount = br.ReadUInt32(); this.channelCount = br.ReadUInt16(); this.channelBlocks = new ChannelSubBlock[this.channelCount]; int index = 0; do { uint blockSig = br.ReadUInt32(); if (blockSig != PSPConstants.blockIdentifier) { throw new System.FormatException(Properties.Resources.InvalidBlockSignature); } PSPBlockID blockType = (PSPBlockID)br.ReadUInt16(); #pragma warning disable IDE0059 // Value assigned to symbol is never used uint chunkLength = br.ReadUInt32(); #pragma warning restore IDE0059 // Value assigned to symbol is never used switch (blockType) { case PSPBlockID.ColorPalette: this.paletteSubBlock = new ColorPaletteBlock(br, PSPConstants.majorVersion5); break; case PSPBlockID.Channel: ChannelSubBlock block = new ChannelSubBlock(br, this.compressionType, PSPConstants.majorVersion5); this.channelBlocks[index] = block; index++; break; } }while (index < this.channelCount); }