public static LineStyleEx ReadLineStyleEx(this ISwfStreamReader reader) { var lineStyle = new LineStyleEx { Width = reader.ReadUInt16(), StartCapStyle = (CapStyle)reader.ReadUnsignedBits(2), JoinStyle = (JoinStyle)reader.ReadUnsignedBits(2), HasFill = reader.ReadBit(), NoHScale = reader.ReadBit(), NoVScale = reader.ReadBit(), PixelHinting = reader.ReadBit(), Reserved = (byte)reader.ReadUnsignedBits(5), NoClose = reader.ReadBit(), EndCapStyle = (CapStyle)reader.ReadUnsignedBits(2) }; if (lineStyle.JoinStyle == JoinStyle.Miter) { lineStyle.MilterLimitFactor = reader.ReadFixedPoint8(); } if (lineStyle.HasFill) { lineStyle.FillStyle = reader.ReadFillStyleRGBA(); } else { lineStyle.Color = reader.ReadRGBA(); } return(lineStyle); }
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 ButtonCondition ReadButtonCondition(this ISwfStreamReader reader) { var res = new ButtonCondition { IdleToOverDown = reader.ReadBit(), OutDownToIdle = reader.ReadBit(), OutDownToOverDown = reader.ReadBit(), OverDownToOutDown = reader.ReadBit(), OverDownToOverUp = reader.ReadBit(), OverUpToOverDown = reader.ReadBit(), OverUpToIdle = reader.ReadBit(), IdleToOverUp = reader.ReadBit(), KeyPress = (byte)reader.ReadUnsignedBits(7), OverDownToIdle = reader.ReadBit() }; var ar = new ActionReader(reader); ActionBase action; do { action = ar.ReadAction(); res.Actions.Add(action); } while (!(action is ActionEnd)); return(res); }
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); }
private StraightEdgeShapeRecord ReadStraigtEdgeShapeRecord(ISwfStreamReader reader) { var record = new StraightEdgeShapeRecord(); var numBits = reader.ReadUnsignedBits(4) + 2; var generalLineFlag = reader.ReadBit(); bool vertLineFlag = false; if (!generalLineFlag) { vertLineFlag = reader.ReadBit(); } if (generalLineFlag || !vertLineFlag) { record.DeltaX = reader.ReadSignedBits(numBits); } if (generalLineFlag || vertLineFlag) { record.DeltaY = reader.ReadSignedBits(numBits); } return(record); }
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 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 T Read(ISwfStreamReader reader, bool allowBigArray, ref uint fillBitsCount, ref uint lineBitsCount) { var isEdge = reader.ReadBit(); if (!isEdge) { bool stateNewStyles = reader.ReadBit(); bool stateLineStyle = reader.ReadBit(); bool stateFillStyle1 = reader.ReadBit(); bool stateFillStyle0 = reader.ReadBit(); bool stateMoveTo = reader.ReadBit(); if (stateNewStyles || stateLineStyle || stateFillStyle1 || stateFillStyle0 || stateMoveTo) { var styleChange = CreateStyleChangeRecord(); styleChange.StateNewStyles = stateNewStyles; styleChange.StateMoveTo = stateMoveTo; if (stateMoveTo) { var moveBits = reader.ReadUnsignedBits(5); styleChange.MoveDeltaX = reader.ReadSignedBits(moveBits); styleChange.MoveDeltaY = reader.ReadSignedBits(moveBits); } if (stateFillStyle0) { styleChange.FillStyle0 = reader.ReadUnsignedBits(fillBitsCount); } if (stateFillStyle1) { styleChange.FillStyle1 = reader.ReadUnsignedBits(fillBitsCount); } if (stateLineStyle) { styleChange.LineStyle = reader.ReadUnsignedBits(lineBitsCount); } if (stateNewStyles) { ReadFillStyles(reader, styleChange, allowBigArray); ReadLineStyles(reader, styleChange, allowBigArray); fillBitsCount = reader.ReadUnsignedBits(4); lineBitsCount = reader.ReadUnsignedBits(4); } return(Adapt(styleChange)); } else { return(Adapt(new EndShapeRecord())); } } var straight = reader.ReadBit(); return(straight ? Adapt(ReadStraigtEdgeShapeRecord(reader)) : Adapt(ReadCurvedEdgeShapeRecord(reader))); }
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 ClipEventFlags ReadClipEventFlags(this ISwfStreamReader reader, byte swfVersion) { var res = new ClipEventFlags { ClipEventKeyUp = reader.ReadBit(), ClipEventKeyDown = reader.ReadBit(), ClipEventMouseUp = reader.ReadBit(), ClipEventMouseDown = reader.ReadBit(), ClipEventMouseMove = reader.ReadBit(), ClipEventUnload = reader.ReadBit(), ClipEventEnterFrame = reader.ReadBit(), ClipEventLoad = reader.ReadBit(), ClipEventDragOver = reader.ReadBit(), ClipEventRollOut = reader.ReadBit(), ClipEventRollOver = reader.ReadBit(), ClipEventReleaseOutside = reader.ReadBit(), ClipEventRelease = reader.ReadBit(), ClipEventPress = reader.ReadBit(), ClipEventInitialize = reader.ReadBit(), ClipEventData = reader.ReadBit(), }; if (swfVersion >= 6) { res.Reserved = (byte)reader.ReadUnsignedBits(5); res.ClipEventConstruct = reader.ReadBit(); res.ClipEventKeyPress = reader.ReadBit(); res.ClipEventDragOut = reader.ReadBit(); res.Reserved2 = reader.ReadByte(); } return(res); }
ActionBase IActionVisitor <ushort, ActionBase> .Visit(ActionGotoFrame2 action, ushort length) { action.Reserved = (byte)_reader.ReadUnsignedBits(6); var hasBias = _reader.ReadBit(); action.Play = _reader.ReadBit(); if (hasBias) { action.SceneBias = _reader.ReadUInt16(); } return(action); }