Beispiel #1
0
        static Filter ReadConcreteFilter(GradientBevelFilter filter, SwfStreamReader reader)
        {
            var num_colors = reader.ReadByte();

            filter.GradientColors = new SwfColor[num_colors];
            for (var i = 0; i < num_colors; ++i)
            {
                filter.GradientColors[i] = SwfColor.Read(reader, true);
            }
            filter.GradientRatio = new byte[num_colors];
            for (var i = 0; i < num_colors; ++i)
            {
                filter.GradientRatio[i] = reader.ReadByte();
            }
            filter.BlurX           = reader.ReadFixedPoint_16_16();
            filter.BlurY           = reader.ReadFixedPoint_16_16();
            filter.Angle           = reader.ReadFixedPoint_16_16();
            filter.Distance        = reader.ReadFixedPoint_16_16();
            filter.Strength        = reader.ReadFixedPoint_8_8();
            filter.InnerShadow     = reader.ReadBit();
            filter.Knockout        = reader.ReadBit();
            filter.CompositeSource = reader.ReadBit();
            filter.OnTop           = reader.ReadBit();
            filter.Passes          = reader.ReadUnsignedBits(4);
            return(filter);
        }
Beispiel #2
0
        public static SwfColor Read(SwfStreamReader reader, bool with_alpha)
        {
            var r = reader.ReadByte();
            var g = reader.ReadByte();
            var b = reader.ReadByte();
            var a = with_alpha ? reader.ReadByte() : byte.MaxValue;

            return(new SwfColor {
                R = r,
                G = g,
                B = b,
                A = a
            });
        }
Beispiel #3
0
        public static DefineBitsLosslessTag Create(SwfStreamReader reader)
        {
            var tag = new DefineBitsLosslessTag();

            tag.CharacterId  = reader.ReadUInt16();
            tag.BitmapFormat = reader.ReadByte();
            tag.BitmapWidth  = reader.ReadUInt16();
            tag.BitmapHeight = reader.ReadUInt16();
            if (tag.BitmapFormat == 3)
            {
                tag.BitmapColorTableSize = (ushort)(reader.ReadByte() + 1);
            }
            tag.ZlibBitmapData = reader.ReadRest();
            return(tag);
        }
Beispiel #4
0
 public static SwfShortHeader Read(SwfStreamReader reader)
 {
     return(new SwfShortHeader {
         Format = new string(reader.ReadChars(3)),
         Version = reader.ReadByte(),
         FileLength = reader.ReadUInt32()
     });
 }
Beispiel #5
0
        public static FrameLabelTag Create(SwfStreamReader reader)
        {
            var tag = new FrameLabelTag();

            tag.Name       = reader.ReadString();
            tag.AnchorFlag = reader.IsEOF ? (byte)0 : reader.ReadByte();
            return(tag);
        }
Beispiel #6
0
        public static SwfFillStyleType Read(SwfStreamReader reader)
        {
            var type_id = reader.ReadByte();

            return(new SwfFillStyleType {
                Value = TypeFromByte(type_id)
            });
        }
Beispiel #7
0
 static Filter ReadConcreteFilter(ConvolutionFilter filter, SwfStreamReader reader)
 {
     filter.MatrixX = reader.ReadByte();
     filter.MatrixY = reader.ReadByte();
     filter.Divisor = reader.ReadFloat32();
     filter.Bias    = reader.ReadFloat32();
     filter.Matrix  = new float[filter.MatrixX * filter.MatrixY];
     for (var i = 0; i < filter.Matrix.Length; ++i)
     {
         filter.Matrix[i] = reader.ReadFloat32();
     }
     filter.DefaultColor = SwfColor.Read(reader, true);
     reader.ReadUnsignedBits(6);             // reserved
     filter.Clamp         = reader.ReadBit();
     filter.PreserveAlpha = reader.ReadBit();
     return(filter);
 }
Beispiel #8
0
        public static SwfBlendMode Read(SwfStreamReader reader)
        {
            var mode_id = reader.ReadByte();

            return(new SwfBlendMode {
                Value = ModeFromByte(mode_id)
            });
        }
Beispiel #9
0
        public static DefineShape4Tag Create(SwfStreamReader reader)
        {
            var tag = new DefineShape4Tag();

            tag.ShapeId     = reader.ReadUInt16();
            tag.ShapeBounds = SwfRect.Read(reader);
            tag.EdgeBounds  = SwfRect.Read(reader);
            tag.Flags       = reader.ReadByte();
            tag.Shapes      = SwfShapesWithStyle.Read(reader, SwfShapesWithStyle.ShapeStyleType.Shape4);
            return(tag);
        }
Beispiel #10
0
        public override byte ReadByte()
        {
            var a = _first.ReadByte();
            var b = _second.ReadByte();

            if (a != b)
            {
                throw new Exception(string.Format("a={0}, b={1}", a, b));
            }
            return(a);
        }
        // -----------------------------
        // Gradient
        // -----------------------------

        static void SkipGradient(SwfStreamReader reader, bool with_alpha)
        {
            reader.ReadUnsignedBits(2);             // SpreadMode
            reader.ReadUnsignedBits(2);             // InterpolationMode
            var count = reader.ReadUnsignedBits(4);

            for (var i = 0; i < count; ++i)
            {
                reader.ReadByte();                 // Ratio
                SwfColor.Read(reader, with_alpha);
            }
        }
Beispiel #12
0
        public static SwfSurfaceFilters Read(SwfStreamReader reader)
        {
            var filter_count = reader.ReadByte();
            var filters      = new List <Filter>(filter_count);

            for (var i = 0; i < filter_count; ++i)
            {
                filters.Add(ReadFilter(reader));
            }
            return(new SwfSurfaceFilters {
                Filters = filters
            });
        }
        // ---------------------------------------------------------------------
        //
        // FillStyles
        //
        // ---------------------------------------------------------------------

        static List <FillStyle> ReadFillStyles(
            SwfStreamReader reader, bool allow_big_array, bool with_alpha)
        {
            ushort count = reader.ReadByte();

            if (allow_big_array && count == 255)
            {
                count = reader.ReadUInt16();
            }
            var styles = new List <FillStyle>(count);

            for (var i = 0; i < count; ++i)
            {
                styles.Add(ReadFillStyle(reader, with_alpha));
            }
            return(styles);
        }
        // ---------------------------------------------------------------------
        //
        // LineStyles
        //
        // ---------------------------------------------------------------------

        static void SkipLineStyles(
            SwfStreamReader reader, bool allow_big_array, bool with_alpha, bool line2_type)
        {
            ushort count = reader.ReadByte();

            if (allow_big_array && count == 255)
            {
                count = reader.ReadUInt16();
            }
            for (var i = 0; i < count; ++i)
            {
                if (line2_type)
                {
                    SkipLine2Style(reader);
                }
                else
                {
                    SkipLineStyle(reader, with_alpha);
                }
            }
        }
Beispiel #15
0
        public static PlaceObject3Tag Create(SwfStreamReader reader)
        {
            var tag = new PlaceObject3Tag();

            tag.HasClipActions    = reader.ReadBit();
            tag.HasClipDepth      = reader.ReadBit();
            tag.HasName           = reader.ReadBit();
            tag.HasRatio          = reader.ReadBit();
            tag.HasColorTransform = reader.ReadBit();
            tag.HasMatrix         = reader.ReadBit();
            tag.HasCharacter      = reader.ReadBit();
            tag.Move = reader.ReadBit();
            reader.ReadBit();             // reserved
            tag.OpaqueBackground = reader.ReadBit();
            tag.HasVisible       = reader.ReadBit();
            tag.HasImage         = reader.ReadBit();
            tag.HasClassName     = reader.ReadBit();
            tag.HasCacheAsBitmap = reader.ReadBit();
            tag.HasBlendMode     = reader.ReadBit();
            tag.HasFilterList    = reader.ReadBit();
            tag.Depth            = reader.ReadUInt16();

            tag.ClassName = tag.HasClassName
                                ? reader.ReadString()
                                : string.Empty;

            tag.CharacterId = tag.HasCharacter
                                ? reader.ReadUInt16()
                                : (ushort)0;

            tag.Matrix = tag.HasMatrix
                                ? SwfMatrix.Read(reader)
                                : SwfMatrix.identity;

            tag.ColorTransform = tag.HasColorTransform
                                ? SwfColorTransform.Read(reader, true)
                                : SwfColorTransform.identity;

            tag.Ratio = tag.HasRatio
                                ? reader.ReadUInt16()
                                : (ushort)0;

            tag.Name = tag.HasName
                                ? reader.ReadString()
                                : string.Empty;

            tag.ClipDepth = tag.HasClipDepth
                                ? reader.ReadUInt16()
                                : (ushort)0;

            tag.SurfaceFilters = tag.HasFilterList
                                ? SwfSurfaceFilters.Read(reader)
                                : SwfSurfaceFilters.identity;

            tag.BlendMode = tag.HasBlendMode
                                ? SwfBlendMode.Read(reader)
                                : SwfBlendMode.identity;

            tag.BitmapCache = tag.HasCacheAsBitmap
                                ? (0 != reader.ReadByte())
                                : false;

            tag.Visible = tag.HasVisible && !reader.IsEOF
                                ? (0 != reader.ReadByte())
                                : true;

            tag.BackgroundColor = tag.HasVisible && !reader.IsEOF
                                ? SwfColor.Read(reader, true)
                                : SwfColor.identity;

            tag.ClipActions = tag.HasClipActions && !reader.IsEOF
                                ? SwfClipActions.Read(reader)
                                : SwfClipActions.identity;

            return(tag);
        }
Beispiel #16
0
        // ---------------------------------------------------------------------
        //
        // ReadFilters
        //
        // ---------------------------------------------------------------------

        static Filter ReadFilter(SwfStreamReader reader)
        {
            var type_id = reader.ReadByte();

            return(CreateFilterFromTypeId(type_id, reader));
        }