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 SwfRect ReadRect(this ISwfStreamReader reader) { SwfRect rect; ReadRect(reader, out rect); return(rect); }
public static ClipActionRecord ReadClipActionRecord(this ISwfStreamReader reader, byte swfVersion) { var record = new ClipActionRecord(); record.Flags = reader.ReadClipEventFlags(swfVersion); if (record.Flags.IsEmpty) { return(record); } var offset = reader.ReadUInt32(); if (record.Flags.ClipEventKeyPress) { record.KeyCode = reader.ReadByte(); } ActionBase action; var ar = new ActionReader(reader); do { action = ar.ReadAction(); record.Actions.Add(action); } while (!(action is ActionEnd)); return(record); }
public static SwfSymbolReference ReadSymbolReference(this ISwfStreamReader reader) { return(new SwfSymbolReference { SymbolID = reader.ReadUInt16(), SymbolName = reader.ReadString() }); }
public static ColorTransformRGBA ReadColorTransformRGBA(this ISwfStreamReader reader) { ColorTransformRGBA transform; reader.ReadColorTransformRGBA(out transform); return(transform); }
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 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 SwfRGB ReadRGB(this ISwfStreamReader reader) { SwfRGB color; reader.ReadRGB(out color); return(color); }
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 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); }
public static LineStyleRGBA ReadLineStyleRGBA(this ISwfStreamReader reader) { var lineStyle = new LineStyleRGBA { Width = reader.ReadUInt16(), Color = reader.ReadRGBA() }; return(lineStyle); }
/// <summary> /// Reads GlyphEntry from reader. /// </summary> /// <param name="reader">Reader from which to read GlyphEntry.</param> /// <param name="glyphBits">Bits count used for reading glyph index.</param> /// <param name="advanceBits">Bits count used for reading advance value.</param> /// <returns></returns> public static GlyphEntry ReadGlyphEntry(this ISwfStreamReader reader, uint glyphBits, uint advanceBits) { var entry = new GlyphEntry { GlyphIndex = reader.ReadUnsignedBits(glyphBits), GlyphAdvance = reader.ReadSignedBits(advanceBits) }; return(entry); }
public static SwfRGBA ReadRGBA(this ISwfStreamReader reader) { return(new SwfRGBA { Red = reader.ReadByte(), Green = reader.ReadByte(), Blue = reader.ReadByte(), Alpha = reader.ReadByte() }); }
public static GradientRecordRGBA ReadGradientRecordRGBA(this ISwfStreamReader reader) { var record = new GradientRecordRGBA { Ratio = reader.ReadByte(), Color = reader.ReadRGBA() }; return(record); }
public static KerningRecord ReadKerningRecord(this ISwfStreamReader reader, bool wideCodes) { var res = new KerningRecord { LeftCode = wideCodes ? reader.ReadUInt16() : reader.ReadByte(), RightCode = wideCodes ? reader.ReadUInt16() : reader.ReadByte(), Adjustment = reader.ReadSInt16() }; return(res); }
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 ReadClipActionRecords(this ISwfStreamReader reader, byte swfVersion, IList <ClipActionRecord> target) { ClipActionRecord record; do { record = reader.ReadClipActionRecord(swfVersion); target.Add(record); } while (!record.Flags.IsEmpty); }
public static SwfHeader ReadSwfHeader(this ISwfStreamReader reader) { var header = new SwfHeader { FrameSize = reader.ReadRect(), FrameRate = reader.ReadFixedPoint8(), FrameCount = reader.ReadUInt16() }; return(header); }
public static void ReadFilterList(this ISwfStreamReader reader, IList <BaseFilter> target) { var count = reader.ReadByte(); for (var i = 0; i < count; i++) { var filter = reader.ReadFilter(); target.Add(filter); } }
private static void ReadActions(ISwfStreamReader reader, int length, IList <ActionBase> actions) { var bytes = reader.ReadBytes(length); var mem = new MemoryStream(bytes); var ar = new ActionReader(new SwfStreamReader(mem)); while (mem.Position != mem.Length) { actions.Add(ar.ReadAction()); } }
private CurvedEdgeShapeRecord ReadCurvedEdgeShapeRecord(ISwfStreamReader reader) { var record = new CurvedEdgeShapeRecord(); var numBits = reader.ReadUnsignedBits(4) + 2; record.ControlDeltaX = reader.ReadSignedBits(numBits); record.ControlDeltaY = reader.ReadSignedBits(numBits); record.AnchorDeltaX = reader.ReadSignedBits(numBits); record.AnchorDeltaY = reader.ReadSignedBits(numBits); return(record); }
public static SwfRGBA ReadARGB(this ISwfStreamReader reader) { var rgb = new SwfRGBA { Alpha = reader.ReadByte(), Red = reader.ReadByte(), Green = reader.ReadByte(), Blue = reader.ReadByte() }; return(rgb); }
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 SwfTagData ReadTagData(this ISwfStreamReader reader) { var typeAndSize = reader.ReadUInt16(); var type = (SwfTagType)(typeAndSize >> 6); var shortSize = typeAndSize & 0x3f; var size = shortSize < 0x3f ? shortSize : reader.ReadInt32(); var tagData = reader.ReadBytes(size); return(new SwfTagData { Type = type, Data = tagData }); }
public static void ReadToLineStylesEx(this ISwfStreamReader reader, IList <LineStyleEx> lineStyles) { ushort cnt = reader.ReadByte(); if (cnt == 255) { cnt = reader.ReadUInt16(); } for (var i = 0; i < cnt; i++) { lineStyles.Add(reader.ReadLineStyleEx()); } }
public static void ReadToLineStylesRGB(this ISwfStreamReader reader, IList <LineStyleRGB> lineStyles, bool allowBigArray) { ushort cnt = reader.ReadByte(); if (allowBigArray && cnt == 255) { cnt = reader.ReadUInt16(); } for (var i = 0; i < cnt; i++) { lineStyles.Add(reader.ReadLineStyleRGB()); } }
public static void ReadToFillStylesRGBA(this ISwfStreamReader reader, IList <FillStyleRGBA> fillStyles) { ushort count = reader.ReadByte(); if (count == 255) { count = reader.ReadUInt16(); } for (var i = 0; i < count; i++) { FillStyleRGBA style = reader.ReadFillStyleRGBA(); fillStyles.Add(style); } }
public static void ReadToFillStylesRGB(this ISwfStreamReader reader, IList <FillStyleRGB> fillStyles, bool allowBigArray) { ushort count = reader.ReadByte(); if (allowBigArray && count == 255) { count = reader.ReadUInt16(); } for (var i = 0; i < count; i++) { FillStyleRGB style = reader.ReadFillStyleRGB(); fillStyles.Add(style); } }
public static void ReadToShapeRecordsEx(this ISwfStreamReader reader, IList <IShapeRecordEx> shapeRecords) { var fillStyleBits = reader.ReadUnsignedBits(4); var lineStyleBits = reader.ReadUnsignedBits(4); reader.AlignToByte(); IShapeRecordEx record; do { record = _shapeRecorExReader.Read(reader, true, ref fillStyleBits, ref lineStyleBits); shapeRecords.Add(record); } while (!(record is EndShapeRecord)); }
/// <summary> /// Reads RGBA gradient from the reader. /// </summary> /// <param name="reader">The reader from which to read gradient.</param> /// <returns></returns> public static GradientRGBA ReadGradientRGBA(this ISwfStreamReader reader) { var gradient = new GradientRGBA { SpreadMode = (SpreadMode)reader.ReadUnsignedBits(2), InterpolationMode = (InterpolationMode)reader.ReadUnsignedBits(2) }; var count = reader.ReadUnsignedBits(4); for (var i = 0; i < count; i++) { GradientRecordRGBA record = reader.ReadGradientRecordRGBA(); gradient.GradientRecords.Add(record); } return(gradient); }
private static void ReadTags(SwfFile file, ISwfStreamReader reader) { while (!reader.IsEOF) { var ser = new SwfTagDeserializer(file); var tagData = reader.ReadTagData(); SwfTagBase tag = ser.ReadTag(tagData); if (tag != null) file.Tags.Add(tag); else throw new InvalidOperationException("Tag can't be null. Loss of data possible"); } }