public static ColorTransformRGB ReadColorTransformRGB(this ISwfStreamReader reader) { ColorTransformRGB transform; var hasAddTerms = reader.ReadBit(); var hasMultTerms = reader.ReadBit(); var bits = reader.ReadUnsignedBits(4); if (hasMultTerms) { transform.RedMultTerm = (short)reader.ReadSignedBits(bits); transform.GreenMultTerm = (short)reader.ReadSignedBits(bits); transform.BlueMultTerm = (short)reader.ReadSignedBits(bits); transform.HasMultTerms = true; } else { transform.RedMultTerm = 0; transform.GreenMultTerm = 0; transform.BlueMultTerm = 0; transform.HasMultTerms = false; } if (hasAddTerms) { transform.RedAddTerm = (short)reader.ReadSignedBits(bits); transform.GreenAddTerm = (short)reader.ReadSignedBits(bits); transform.BlueAddTerm = (short)reader.ReadSignedBits(bits); transform.HasAddTerms = true; } else { transform.RedAddTerm = 0; transform.GreenAddTerm = 0; transform.BlueAddTerm = 0; transform.HasAddTerms = false; } reader.AlignToByte(); return transform; }
public static ButtonRecordEx ReadButtonRecordEx(this ISwfStreamReader reader) { var button = new ButtonRecordEx(); button.Reserved = (byte)reader.ReadUnsignedBits(2); var hasBlendMode = reader.ReadBit(); var hasFilterList = reader.ReadBit(); button.StateHitTest = reader.ReadBit(); button.StateDown = reader.ReadBit(); button.StateOver = reader.ReadBit(); button.StateUp = reader.ReadBit(); var isEnd = !hasBlendMode && !hasFilterList && button.IsEndButton; if (!isEnd) { button.CharacterID = reader.ReadUInt16(); button.PlaceDepth = reader.ReadUInt16(); button.PlaceMatrix = reader.ReadMatrix(); button.ColorTransform = reader.ReadColorTransformRGBA(); reader.AlignToByte(); if (hasFilterList) { reader.ReadFilterList(button.Filters); } if (hasBlendMode) { button.BlendMode = (BlendMode)reader.ReadByte(); } } return button; }
public static void ReadColorTransformRGBA(this ISwfStreamReader reader, out ColorTransformRGBA transform) { var hasAddTerms = reader.ReadBit(); var hasMultTerms = reader.ReadBit(); var bits = reader.ReadUnsignedBits(4); if (hasMultTerms) { transform.RedMultTerm = (short)reader.ReadSignedBits(bits); transform.GreenMultTerm = (short)reader.ReadSignedBits(bits); transform.BlueMultTerm = (short)reader.ReadSignedBits(bits); transform.AlphaMultTerm = (short)reader.ReadSignedBits(bits); transform.HasMultTerms = true; } else { transform.RedMultTerm = 0; transform.GreenMultTerm = 0; transform.BlueMultTerm = 0; transform.AlphaMultTerm = 0; transform.HasMultTerms = false; } if (hasAddTerms) { transform.RedAddTerm = (short)reader.ReadSignedBits(bits); transform.GreenAddTerm = (short)reader.ReadSignedBits(bits); transform.BlueAddTerm = (short)reader.ReadSignedBits(bits); transform.AlphaAddTerm = (short)reader.ReadSignedBits(bits); transform.HasAddTerms = true; } else { transform.RedAddTerm = 0; transform.GreenAddTerm = 0; transform.BlueAddTerm = 0; transform.AlphaAddTerm = 0; transform.HasAddTerms = false; } reader.AlignToByte(); }
public static void ReadRect(this ISwfStreamReader reader, out SwfRect rect) { var bits = reader.ReadUnsignedBits(5); rect.XMin = reader.ReadSignedBits(bits); rect.XMax = reader.ReadSignedBits(bits); rect.YMin = reader.ReadSignedBits(bits); rect.YMax = reader.ReadSignedBits(bits); reader.AlignToByte(); }
public static void ReadToShapeRecordsRGBA(this ISwfStreamReader reader, IList<IShapeRecordRGBA> shapeRecords) { var fillStyleBits = reader.ReadUnsignedBits(4); var lineStyleBits = reader.ReadUnsignedBits(4); reader.AlignToByte(); IShapeRecordRGBA record; do { record = _shapeRecordRGBAReader.Read(reader, true, ref fillStyleBits, ref lineStyleBits); shapeRecords.Add(record); } while (!(record is EndShapeRecord)); }
public static SwfMatrix ReadMatrix(this ISwfStreamReader reader) { var matrix = SwfMatrix.Identity; var hasScale = reader.ReadBit(); if (hasScale) { var bits = (byte)reader.ReadUnsignedBits(5); matrix.ScaleX = reader.ReadFixedPoint16(bits); matrix.ScaleY = reader.ReadFixedPoint16(bits); } var hasRotate = reader.ReadBit(); if (hasRotate) { var bits = (byte)reader.ReadUnsignedBits(5); matrix.RotateSkew0 = reader.ReadFixedPoint16(bits); matrix.RotateSkew1 = reader.ReadFixedPoint16(bits); } var translateBits = (byte)reader.ReadUnsignedBits(5); matrix.TranslateX = reader.ReadSignedBits(translateBits); matrix.TranslateY = reader.ReadSignedBits(translateBits); reader.AlignToByte(); return matrix; }
public static IList<TextRecordRGB> ReadTextRecordsRGB(this ISwfStreamReader reader, uint glyphBits, uint advanceBits) { var res = new List<TextRecordRGB>(); bool isEnd; do { var record = new TextRecordRGB(); record.Type = reader.ReadBit(); record.Reserved = (byte)reader.ReadUnsignedBits(3); var hasFont = reader.ReadBit(); var hasColor = reader.ReadBit(); var hasYOffset = reader.ReadBit(); var hasXOffset = reader.ReadBit(); isEnd = !record.Type && record.Reserved == 0 && !hasFont && !hasColor && !hasYOffset && !hasXOffset; if (!isEnd) { record.FontID = hasFont ? (ushort?)reader.ReadUInt16() : null; if (hasColor) { record.TextColor = reader.ReadRGB(); } if (hasXOffset) { record.XOffset = reader.ReadSInt16(); } if (hasYOffset) { record.YOffset = reader.ReadSInt16(); } if (hasFont) { record.TextHeight = reader.ReadUInt16(); } var count = reader.ReadByte(); for (var i = 0; i < count; i++) { var entry = reader.ReadGlyphEntry(glyphBits, advanceBits); record.Glyphs.Add(entry); } reader.AlignToByte(); } res.Add(record); } while (!isEnd); return res; }