Пример #1
0
        public FillStyleRGBA Read(ISwfStreamReader reader, FillStyleType type)
        {
            var fillStyle = _factory.CreateRGBA(type);

            fillStyle.AcceptVisitor(this, reader);
            return(fillStyle);
        }
Пример #2
0
        private static string GetNodeName(FillStyleType type)
        {
            switch (type)
            {
            case FillStyleType.RepeatingBitmap:
                return(REPEATING_BITMAP);

            case FillStyleType.ClippedBitmap:
                return(CLIPPED_BITMAP);

            case FillStyleType.NonSmoothedRepeatingBitmap:
                return(NON_SMOOTHED_REPEATING_BITMAP);

            case FillStyleType.NonSmoothedClippedBitmap:
                return(NON_SMOOTHED_CLIPPED_BITMAP);

            default:
                throw new NotSupportedException();
            }
        }
Пример #3
0
        public FillStyleRGBA CreateRGBA(FillStyleType type)
        {
            switch (type)
            {
            case FillStyleType.SolidColor:
                return(new SolidFillStyleRGBA());

            case FillStyleType.LinearGradient:
                return(new LinearGradientFillStyleRGBA());

            case FillStyleType.RadialGradient:
                return(new RadialGradientFillStyleRGBA());

            case FillStyleType.FocalGradient:
                return(new FocalGradientFillStyleRGBA());

            case FillStyleType.RepeatingBitmap:
                return(new BitmapFillStyleRGBA {
                    Smoothing = true, Mode = BitmapMode.Repeat
                });

            case FillStyleType.ClippedBitmap:
                return(new BitmapFillStyleRGBA {
                    Smoothing = true, Mode = BitmapMode.Clip
                });

            case FillStyleType.NonSmoothedRepeatingBitmap:
                return(new BitmapFillStyleRGBA {
                    Smoothing = false, Mode = BitmapMode.Repeat
                });

            case FillStyleType.NonSmoothedClippedBitmap:
                return(new BitmapFillStyleRGBA {
                    Smoothing = false, Mode = BitmapMode.Clip
                });

            default:
                throw new NotSupportedException();
            }
        }
Пример #4
0
 public FillStyleRGB CreateRGB(FillStyleType type)
 {
     switch (type) {
         case FillStyleType.SolidColor:
             return new SolidFillStyleRGB();
         case FillStyleType.LinearGradient:
             return new LinearGradientFillStyleRGB();
         case FillStyleType.RadialGradient:
             return new RadialGradientFillStyleRGB();
         case FillStyleType.FocalGradient:
             return new FocalGradientFillStyleRGB();
         case FillStyleType.RepeatingBitmap:
             return new BitmapFillStyleRGB { Smoothing = true, Mode = BitmapMode.Repeat};
         case FillStyleType.ClippedBitmap:
             return new BitmapFillStyleRGB { Smoothing = true, Mode = BitmapMode.Clip};
         case FillStyleType.NonSmoothedRepeatingBitmap:
             return new BitmapFillStyleRGB { Smoothing = false, Mode = BitmapMode.Repeat };
         case FillStyleType.NonSmoothedClippedBitmap:
             return new BitmapFillStyleRGB { Smoothing = false, Mode = BitmapMode.Clip};
         default:
             throw new NotSupportedException();
     }
 }
Пример #5
0
 private static string GetNodeName(FillStyleType type)
 {
     switch (type) {
         case FillStyleType.RepeatingBitmap:
             return REPEATING_BITMAP;
         case FillStyleType.ClippedBitmap:
             return CLIPPED_BITMAP;
         case FillStyleType.NonSmoothedRepeatingBitmap:
             return NON_SMOOTHED_REPEATING_BITMAP;
         case FillStyleType.NonSmoothedClippedBitmap:
             return NON_SMOOTHED_CLIPPED_BITMAP;
         default:
             throw new NotSupportedException();
     }
 }
Пример #6
0
 public FillStyle(Character ImageFill, BitmapFill bitmapFill)
 {
     this._ImageFill = ImageFill;
     this._Type = (FillStyleType) bitmapFill;
 }
Пример #7
0
 public FillStyle(Gradient FillGradient)
 {
     this._Gradient = FillGradient;
     this._Type = (FillStyleType) FillGradient.Type;
 }
Пример #8
0
 public FillStyle(RGB SolidFillColor)
 {
     this._SolidColor = SolidFillColor;
     this._Type = FillStyleType.Solid;
 }
Пример #9
0
 /// <summary>
 /// Creates a new <see cref="GradientFill"/> instance.
 /// </summary>
 /// <param name="fillStyleType">Fill style type.</param>
 /// <param name="gradientTransform">Gradient transform.</param>
 /// <param name="gradients">Gradients.</param>
 public GradientFill(FillStyleType fillStyleType, Matrix gradientTransform, GradientRecordCollection gradients)
 {
     this.gradientMatrix = gradientTransform;
     this.gradient       = gradients;
     this.fillStyleType  = (byte)fillStyleType;
 }
Пример #10
0
 /// <summary>
 /// Creates a new <see cref="GradientFill"/> instance.
 /// </summary>
 public GradientFill(FillStyleType fillStyleType)
 {
     this.fillStyleType = (byte)fillStyleType;
 }
Пример #11
0
 public FillStyle(Character ImageFill, BitmapFill bitmapFill)
 {
     this._ImageFill = ImageFill;
     this._Type      = (FillStyleType)bitmapFill;
 }
Пример #12
0
 public FillStyle(Gradient FillGradient)
 {
     this._Gradient = FillGradient;
     this._Type     = (FillStyleType)FillGradient.Type;
 }
Пример #13
0
 public FillStyle(RGB SolidFillColor)
 {
     this._SolidColor = SolidFillColor;
     this._Type       = FillStyleType.Solid;
 }
Пример #14
0
 /// <summary>
 /// Creates a new <see cref="BitmapFill"/> instance.
 /// </summary>
 /// <param name="fillStyleType">Fill style type.</param>
 /// <param name="bitmapId">Bitmap id.</param>
 /// <param name="bitmapTransform">Bitmap transform.</param>
 public BitmapFill(FillStyleType fillStyleType, ushort bitmapId, Matrix bitmapTransform)
 {
     this.fillStyleType = (byte)fillStyleType;
     this.bitmapId      = bitmapId;
     this.bitmapMatrix  = bitmapTransform;
 }
Пример #15
0
 /// <summary>
 /// Creates a new <see cref="BitmapFill"/> instance.
 /// </summary>
 /// <param name="fillStyleType">Fill style type.</param>
 public BitmapFill(FillStyleType fillStyleType)
 {
     this.fillStyleType = (byte)fillStyleType;
 }
Пример #16
0
 /// <summary>
 /// Creates a new <see cref="BitmapFill"/> instance.
 /// </summary>
 /// <param name="fillStyleType">Fill style type.</param>
 public BitmapFill(FillStyleType fillStyleType)
 {
     this.fillStyleType = (byte)fillStyleType;
 }
Пример #17
0
 /// <summary>
 /// Creates a new <see cref="BitmapFill"/> instance.
 /// </summary>
 /// <param name="fillStyleType">Fill style type.</param>
 /// <param name="bitmapId">Bitmap id.</param>
 /// <param name="bitmapTransform">Bitmap transform.</param>
 public BitmapFill(FillStyleType fillStyleType, ushort bitmapId, Matrix bitmapTransform)
 {
     this.fillStyleType = (byte)fillStyleType;
     this.bitmapId = bitmapId;
     this.bitmapMatrix = bitmapTransform;
 }
Пример #18
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="input"></param>
        /// <param name="caller"></param>
        public void Parse(Stream input, TagTypes caller)
        {
            BinaryReader br = new BinaryReader(input);

            this._caller = caller;
            this._fillStyleType = (FillStyleType)br.ReadByte();

            if (this._fillStyleType.Equals(FillStyleType.SolidFill))
            {
                if (caller.Equals(TagTypes.DefineShape3) )
                {
                    this._color = new Rgba(this._SwfVersion);

                    try
                    {
                        this._color.Parse(input);
                        //Log.InfoFormat("Valid fill style type. FillstyleType: 0x{0:X2} at address: 0x{1:X2} in {2}", (Int32)this._fillStyleType, ((Int32)input.Position) - 1, caller);
                    }
                    catch (SwfFormatException e)
                    {
                        throw e;
                    }

                }
                else if (caller.Equals(TagTypes.DefineShape4))
                {
                    this._color = new Rgba(this._SwfVersion);

                    try
                    {
                        this._color.Parse(input);
                    }
                    catch (SwfFormatException e)
                    {
                        throw e;
                    }
                }
                else
                {
                    this._color = new Rgb(this._SwfVersion);

                    try
                    {
                        this._color.Parse(input);
                    }
                    catch (SwfFormatException e)
                    {
                        throw e;
                    }
                }
            }
            else if (this._fillStyleType.Equals(FillStyleType.LinearGradientFill) || this._fillStyleType.Equals(FillStyleType.RadialGradientFill))
            {
                this._gradientMatrix = new Matrix(this._SwfVersion);

                try
                {
                    this._gradientMatrix.Parse(input);
                }
                catch (SwfFormatException e)
                {
                    throw e;
                }

                this._gradient = new Gradient(this._SwfVersion);

                try
                {
                    this._gradient.Parse(input, caller);
                    //Log.InfoFormat("Valid fill style type. FillstyleType: 0x{0:X2} at address: 0x{1:X4} in {2}", (Int32)this._fillStyleType, ((Int32)input.Position) - 1, caller);
                }
                catch (SwfFormatException e)
                {
                    throw e;
                }

            }
            else if (this._fillStyleType.Equals(FillStyleType.FocalRadialGradientFill))
            {
                if (this._SwfVersion >= 8)
                {
                    this._gradientMatrix = new Matrix(this._SwfVersion);

                    try
                    {
                        this._gradientMatrix.Parse(input);

                    }
                    catch(SwfFormatException e)
                    {
                        throw e;
                    }

                    this._gradient = new FocalGradient(this._SwfVersion);

                    try
                    {
                        this._gradient.Parse(input, caller);
                        //Log.InfoFormat("Valid fill style type. FillstyleType: 0x{0:X2} at address: 0x{1:X4} in {2}", (Int32)this._fillStyleType, ((Int32)input.Position) - 1, caller);
                    }
                    catch (SwfFormatException e)
                    {
                        throw e;
                    }

                }
                else
                {
                    SwfFormatException e = new SwfFormatException("Focal gradients are supported by Swf 8 and later only. This version is: " + this._SwfVersion.ToString());
                   Log.Error(this, e);
                }
            }
            else if (this._fillStyleType.Equals(FillStyleType.RepeatingBitmapFill) ||
                      this._fillStyleType.Equals(FillStyleType.ClippedBitmapFill) ||
                      this._fillStyleType.Equals(FillStyleType.NonSmoothedRepeatingBitmap) ||
                      this._fillStyleType.Equals(FillStyleType.NonSmoothedClippedBitmap))
            {
                this._bitmapID = br.ReadUInt16();
                this._bitmapMatrix = new Matrix(this._SwfVersion);

                try
                {
                    this._bitmapMatrix.Parse(input);
                    //Log.InfoFormat("Valid fill style type. FillstyleType: 0x{0:X2} at address: 0x{1:X4} in {2}", (Int32)this._fillStyleType, ((Int32)input.Position) - 1, caller);
                }
                catch (SwfFormatException e)
                {
                    throw e;
                }

            }
            else
            {
                SwfFormatException e = new SwfFormatException("Invalid fill style type! (" + this._fillStyleType +")" +" caller: " + caller.ToString());
                Log.Error(this, e);
                throw e;
            }
        }
Пример #19
0
 /// <summary>
 /// Creates a new <see cref="GradientFill"/> instance.
 /// </summary>
 /// <param name="fillStyleType">Fill style type.</param>
 /// <param name="gradientTransform">Gradient transform.</param>
 /// <param name="gradients">Gradients.</param>
 public GradientFill(FillStyleType fillStyleType, Matrix gradientTransform, GradientRecordCollection gradients)
 {
     this.gradientMatrix = gradientTransform;
     this.gradient = gradients;
     this.fillStyleType = (byte)fillStyleType;
 }
Пример #20
0
 /// <summary>
 /// Creates a new <see cref="GradientFill"/> instance.
 /// </summary>
 public GradientFill(FillStyleType fillStyleType)
 {
     this.fillStyleType = (byte)fillStyleType;
 }