internal Rect(SwfReader r) { r.Align(); byte minBits = (byte)r.GetBits(5); XMin = r.GetSignedNBits(minBits); XMax = r.GetSignedNBits(minBits); YMin = r.GetSignedNBits(minBits); YMax = r.GetSignedNBits(minBits); r.Align(); }
internal SoundStreamHeadTag(SwfReader r) : base(TagType.SoundStreamHead2) { SoundId = soundIdCounter++; r.GetBits(4); // reserved PlaybackSoundRate = rates[r.GetBits(2)]; PlaybackSoundSize = r.GetBit() ? 16u : 0u; IsStereo = r.GetBit(); StreamSoundCompression = (SoundCompressionType)r.GetBits(4); // Mp3 == 2 StreamSoundRate = rates[r.GetBits(2)]; StreamSoundSize = r.GetBit() ? 16u : 8u; StreamIsStereo = r.GetBit(); r.Align(); StreamSoundSampleCount = r.GetUI16(); if (StreamSoundCompression == SoundCompressionType.MP3) { LatencySeek = r.GetUI16(); } }
internal DefineSoundTag(SwfReader r, uint tagLen) : base(TagType.DefineSound) { SoundId = r.GetUI16(); SoundFormat = (SoundCompressionType)r.GetBits(4); uint sr = r.GetBits(2); switch (sr) { case 0: SoundRate = 5512; // ? break; case 1: SoundRate = 11025; break; case 2: SoundRate = 22050; break; case 3: SoundRate = 44100; break; } SoundSize = r.GetBit() ? 16U : 8U; IsStereo = r.GetBit(); r.Align(); SoundSampleCount = r.GetUI32(); // todo: this needs to decompress if mp3 etc SoundData = r.GetBytes(tagLen - 7); }
internal FilterGradientBevel(SwfReader r) { NumColors = (uint)r.GetByte(); GradientColors = new RGBA[NumColors]; for (int i = 0; i < NumColors; i++) { GradientColors[i] = new RGBA(r.GetByte(), r.GetByte(), r.GetByte(), r.GetByte()); } GradientRatio = new uint[NumColors]; for (int i = 0; i < NumColors; i++) { GradientRatio[i] = (uint)r.GetByte(); } BlurX = r.GetFixed16_16(); BlurY = r.GetFixed16_16(); Angle = r.GetFixed16_16(); Distance = r.GetFixed16_16(); Strength = r.GetFixed8_8(); InnerShadow = r.GetBit(); Knockout = r.GetBit(); CompositeSource = r.GetBit(); OnTop = r.GetBit(); Passes = r.GetBits(4); r.Align(); }
// only used for glyphs internal Shape(SwfReader r) { r.Align(); fillBits = r.GetBits(4); // always one lineBits = r.GetBits(4); // always zero ParseShapeRecords(r); }
internal ShapeWithStyle(SwfReader r, ShapeType shapeType) { this.shapeType = shapeType; // parse fill defs FillStyles = new FillStyleArray(r, shapeType); // parse line defs LineStyles = new LineStyleArray(r, shapeType); r.Align(); fillBits = r.GetBits(4); lineBits = r.GetBits(4); r.Align(); ParseShapeRecords(r); }
internal GetURL2(SwfReader r) { SendVarsMethod = (SendVarsMethod)r.GetBits(2); r.GetBits(4); // reserved TargetIsSprite = r.GetBit(); LoadVariables = r.GetBit(); r.Align(); }
internal FilterBlur(SwfReader r) { BlurX = r.GetFixed16_16(); BlurY = r.GetFixed16_16(); Passes = r.GetBits(5); r.GetBits(3); // reserved r.Align(); }
internal DefineShapeTag(SwfReader r) : base(TagType.DefineShape) { this.CharacterId = r.GetUI16(); this.ShapeBounds = new Rect(r); this.Shapes = new ShapeWithStyle(r, ShapeType.DefineShape1); r.Align(); }
internal Matrix(SwfReader r) { float sx = 1.0F; float sy = 1.0F; float r0 = 0.0F; float r1 = 0.0F; float tx = 0.0F; float ty = 0.0F; r.Align(); bool hasScale = r.GetBit(); if (hasScale) { uint scaleBits = r.GetBits(5); sx = r.GetFixedNBits(scaleBits); sy = r.GetFixedNBits(scaleBits); } bool hasRotate = r.GetBit(); if (hasRotate) { uint nRotateBits = r.GetBits(5); r0 = r.GetFixedNBits(nRotateBits); r1 = r.GetFixedNBits(nRotateBits); } // always has translation uint nTranslateBits = r.GetBits(5); tx = r.GetSignedNBits(nTranslateBits); ty = r.GetSignedNBits(nTranslateBits); r.Align(); this.ScaleX = sx; this.Rotate0 = r0; this.Rotate1 = r1; this.ScaleY = sy; this.TranslateX = tx; this.TranslateY = ty; }
internal DefineShape4Tag(SwfReader r) : base(TagType.DefineShape4) { this.CharacterId = r.GetUI16(); this.ShapeBounds = new Rect(r); this.EdgeBounds = new Rect(r); r.SkipBits(6); this.UsesNonScalingStrokes = r.GetBit(); this.UsesScalingStrokes = r.GetBit(); this.Shapes = new ShapeWithStyle(r, ShapeType.DefineShape4); r.Align(); }
internal CSMTextSettingsTag(SwfReader r) : base(TagType.CSMTextSettings) { TextId = r.GetUI16(); UseFlashType = r.GetBits(2); GridFit = r.GetBits(3); r.GetBits(3); // reserved r.Align(); Thickness = r.GetFixedNBits(32); Sharpness = r.GetFixedNBits(32); r.GetByte(); // reserved }
internal FilterGlow(SwfReader r) { GlowColor = new RGBA(r.GetByte(), r.GetByte(), r.GetByte(), r.GetByte()); BlurX = r.GetFixed16_16(); BlurY = r.GetFixed16_16(); Strength = r.GetFixed8_8(); InnerGlow = r.GetBit(); Knockout = r.GetBit(); CompositeSource = r.GetBit(); Passes = r.GetBits(5); r.Align(); }
internal GotoFrame2(SwfReader r) { r.GetBits(6); // reserved SceneBiasFlag = r.GetBit(); PlayFlag = r.GetBit(); r.Align(); if (SceneBiasFlag) { SceneBias = r.GetUI16(); } else { SceneBias = 0; } }
internal FilterDropShadow(SwfReader r) { DropShadowColor = new RGBA(r.GetByte(), r.GetByte(), r.GetByte(), r.GetByte()); BlurX = r.GetFixed16_16(); BlurY = r.GetFixed16_16(); Angle = r.GetFixed16_16(); Distance = r.GetFixed16_16(); Strength = r.GetFixed8_8(); InnerShadow = r.GetBit(); Knockout = r.GetBit(); CompositeSource = r.GetBit(); Passes = (uint)r.GetBits(5); r.Align(); }
internal DefineShapeTag(SwfReader r, uint tagType) : base(tagType) { this.CharacterId = r.GetUI16(); this.ShapeBounds = new Rect(r); if (tagType == TagType.DefineShape) { this.Shapes = new ShapeWithStyle(r, ShapeType.DefineShape1); } else if (tagType == TagType.DefineShape2) { this.Shapes = new ShapeWithStyle(r, ShapeType.DefineShape2); } else if (tagType == TagType.DefineShape3) { this.Shapes = new ShapeWithStyle(r, ShapeType.DefineShape3); } r.Align(); }
internal FilterBevel(SwfReader r) { ShadowColor = new RGBA(r.GetByte(), r.GetByte(), r.GetByte(), r.GetByte()); HighlightColor = new RGBA(r.GetByte(), r.GetByte(), r.GetByte(), r.GetByte()); BlurX = r.GetFixed16_16(); BlurY = r.GetFixed16_16(); Angle = r.GetFixed16_16(); Distance = r.GetFixed16_16(); Strength = r.GetFixed8_8(); InnerShadow = r.GetBit(); Knockout = r.GetBit(); CompositeSource = r.GetBit(); OnTop = r.GetBit(); Passes = r.GetBits(4); r.Align(); }
internal DefineFontAlignZonesTag(SwfReader r, Dictionary <uint, DefineFont2_3> fonts) : base(TagType.DefineFontAlignZones) { Fonts = fonts; FontId = r.GetUI16(); CSMTableHint = r.GetBits(2); r.SkipBits(6); r.Align(); DefineFont2_3 font = Fonts[FontId]; uint glyphCount = font.NumGlyphs; ZoneTable = new ZoneRecord[glyphCount]; for (int i = 0; i < glyphCount; i++) { ZoneTable[i] = new ZoneRecord(r); } }
internal SoundInfo(SwfReader r) { r.GetBits(2); // reserved IsSyncStop = r.GetBit(); IsSyncNoMultiple = r.GetBit(); HasEnvelope = r.GetBit(); HasLoops = r.GetBit(); HasOutPoint = r.GetBit(); r.Align(); if (HasInPoint) { InPoint = r.GetUI32(); } if (HasOutPoint) { OutPoint = r.GetUI32(); } if (HasLoops) { LoopCount = r.GetUI16(); } if (HasEnvelope) { uint count = (uint)r.GetByte(); uint pos; uint left; uint right; EnvelopeRecords = new SoundEnvelope[count]; for (int i = 0; i < count; i++) { pos = r.GetUI32(); left = r.GetUI16(); right = r.GetUI16(); EnvelopeRecords[i] = new SoundEnvelope(pos, left, right); } } }
internal FilterConvolution(SwfReader r) { MatrixX = (uint)r.GetByte(); MatrixY = (uint)r.GetByte(); Divisor = r.GetFloat32(); Bias = r.GetFloat32(); uint mxCount = MatrixX * MatrixY; Matrix = new float[mxCount]; for (int i = 0; i < mxCount; i++) { Matrix[i] = r.GetFloat32(); } DefaultColor = new RGBA(r.GetByte(), r.GetByte(), r.GetByte(), r.GetByte()); r.GetBits(6); Clamp = r.GetBit(); PreserveAlpha = r.GetBit(); r.Align(); }
internal ColorTransform(SwfReader r, bool useAlpha) { this.HasAddTerms = r.GetBit(); this.HasMultTerms = r.GetBit(); uint nbits = r.GetBits(4); if (HasMultTerms) { RMultTerm = r.GetSignedNBits(nbits); GMultTerm = r.GetSignedNBits(nbits); BMultTerm = r.GetSignedNBits(nbits); AMultTerm = (useAlpha) ? r.GetSignedNBits(nbits) : 0xFF; } else { RMultTerm = 0; GMultTerm = 0; BMultTerm = 0; AMultTerm = 0; } if (HasAddTerms) { RAddTerm = r.GetSignedNBits(nbits); GAddTerm = r.GetSignedNBits(nbits); BAddTerm = r.GetSignedNBits(nbits); AAddTerm = (useAlpha) ? r.GetSignedNBits(nbits) : 0xFF; } else { RAddTerm = 0; GAddTerm = 0; BAddTerm = 0; AAddTerm = 0; } r.Align(); }
internal DefineFont2_3(SwfReader r, bool isHighRes) : base(TagType.DefineFont2) { this.IsHighRes = isHighRes; // true; if (isHighRes) { this.tagType = TagType.DefineFont3; } this.FontId = r.GetUI16(); this.FontFlagsHasLayout = r.GetBit(); this.FontFlagsShiftJIS = r.GetBit(); this.FontFlagsSmallText = r.GetBit(); this.FontFlagsANSI = r.GetBit(); this.FontFlagsWideOffsets = r.GetBit(); this.FontFlagsWideCodes = r.GetBit(); this.FontFlagsItalic = r.GetBit(); this.FontFlagsBold = r.GetBit(); r.Align(); this.LanguageCode = (uint)r.GetByte(); uint fontNameLen = (uint)r.GetByte(); this.FontName = r.GetString(fontNameLen); this.NumGlyphs = r.GetUI16(); this.OffsetTable = new uint[this.NumGlyphs]; for (int i = 0; i < this.NumGlyphs; i++) { this.OffsetTable[i] = this.FontFlagsWideOffsets ? r.GetUI32() : r.GetUI16(); } this.CodeTableOffset = this.FontFlagsWideOffsets ? r.GetUI32() : r.GetUI16(); GlyphShapeTable = new List <Shape>(); for (int i = 0; i < this.NumGlyphs; i++) { Shape s = new Shape(r); GlyphShapeTable.Add(s); } this.CodeTable = new uint[this.NumGlyphs]; for (int i = 0; i < this.NumGlyphs; i++) { this.CodeTable[i] = r.GetUI16(); } if (this.FontFlagsHasLayout) { this.FontAscent = r.GetInt16(); this.FontDescent = r.GetInt16(); this.FontLeading = r.GetInt16(); this.FontAdvanceTable = new int[this.NumGlyphs]; for (int i = 0; i < this.NumGlyphs; i++) { this.FontAdvanceTable[i] = r.GetInt16(); } this.FontBoundsTable = new Rect[this.NumGlyphs]; for (int i = 0; i < this.NumGlyphs; i++) { this.FontBoundsTable[i] = new Rect(r); } this.KerningCount = r.GetUI16(); this.FontKerningTable = new KerningRecord[this.KerningCount]; if (this.FontFlagsWideCodes) { for (int i = 0; i < this.KerningCount; i++) { this.FontKerningTable[i] = new KerningRecord(r.GetUI16(), r.GetUI16(), r.GetInt16()); } } else { for (int i = 0; i < this.KerningCount; i++) { this.FontKerningTable[i] = new KerningRecord((uint)r.GetByte(), (uint)r.GetByte(), r.GetInt16()); } } } }