Exemplo n.º 1
0
 public static SwfRGBA ReadRGBA(this ISwfStreamReader reader)
 {
     return(new SwfRGBA {
         Red = reader.ReadByte(),
         Green = reader.ReadByte(),
         Blue = reader.ReadByte(),
         Alpha = reader.ReadByte()
     });
 }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        public static GradientRecordRGBA ReadGradientRecordRGBA(this ISwfStreamReader reader)
        {
            var record = new GradientRecordRGBA {
                Ratio = reader.ReadByte(),
                Color = reader.ReadRGBA()
            };

            return(record);
        }
Exemplo n.º 8
0
        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);
            }
        }
Exemplo n.º 9
0
        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());
            }
        }
Exemplo n.º 10
0
        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());
            }
        }
Exemplo n.º 11
0
        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);
            }
        }
Exemplo n.º 12
0
        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);
            }
        }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
        public static SwfFileInfo ReadSwfFileInfo(this ISwfStreamReader writer)
        {
            SwfFileInfo header;
            var         sig = new string(new[] { (char)writer.ReadByte(), (char)writer.ReadByte(), (char)writer.ReadByte() });

            if (!Enum.TryParse(sig, true, out header.Format))
            {
                throw new InvalidFormatException("Unsupported File Format");
            }
            header.Version = writer.ReadByte();
            uint len = 0;

            len = len | ((uint)writer.ReadByte() << 0);
            len = len | ((uint)writer.ReadByte() << 8);
            len = len | ((uint)writer.ReadByte() << 16);
            len = len | ((uint)writer.ReadByte() << 24);
            header.FileLength = len;
            return(header);
        }
Exemplo n.º 15
0
 public static void ReadRGB(this ISwfStreamReader reader, out SwfRGB color)
 {
     color.Red   = reader.ReadByte();
     color.Green = reader.ReadByte();
     color.Blue  = reader.ReadByte();
 }
Exemplo n.º 16
0
        public ActionBase ReadAction()
        {
            var    code   = (ActionCode)_reader.ReadByte();
            ushort length = (byte)code >= 0x80 ? _reader.ReadUInt16() : (ushort)0;
            var    action = _factory.Create(code);

            action.AcceptVisitor(this, length);
            return(action);
        }
Exemplo n.º 17
0
        public static FillStyleRGBA ReadFillStyleRGBA(this ISwfStreamReader reader)
        {
            var type = (FillStyleType)reader.ReadByte();

            return(_readerRGBA.Read(reader, type));
        }