SwfDotNet.IO.Tags.Types.FillStyle.ReadData C# (CSharp) Méthode

ReadData() public méthode

Reads the data.
public ReadData ( BufferedBinaryReader binaryReader, ShapeType shapeType ) : void
binaryReader SwfDotNet.IO.Utils.BufferedBinaryReader Binary reader.
shapeType ShapeType Shape type.
Résultat void
        public void ReadData(BufferedBinaryReader binaryReader, ShapeType shapeType)
        {
            base.SetStartPoint(binaryReader);

            fillStyleType = binaryReader.ReadByte();
            rgbColor = null;
            gradientMatrix = null;
            bitmapId = 0;
            bitmapMatrix = null;
            gradient = null;

            if (fillStyleType == (byte)FillStyleType.SolidFill)
            {
                if (shapeType == ShapeType.Shape3)
                {
                    rgbColor = new RGBA();
                    rgbColor.ReadData(binaryReader);
                }
                else if (shapeType == ShapeType.Shape2 || shapeType == ShapeType.Shape)
                {
                    rgbColor = new RGB();
                    rgbColor.ReadData(binaryReader);
                }
            }

            if (fillStyleType == (byte)FillStyleType.RadialGradientFill ||
                fillStyleType == (byte)FillStyleType.LinearGradientFill)
            {
                gradientMatrix = new Matrix();
                gradientMatrix.ReadData(binaryReader);
                gradient = new GradientRecordCollection();
                gradient.ReadData(binaryReader, shapeType);
            }

            if (fillStyleType == (byte)FillStyleType.RepeatingBitmapFill ||
                fillStyleType == (byte)FillStyleType.ClippedBitmapFill ||
                fillStyleType == (byte)FillStyleType.NonSmoothedClippedBitmap ||
                fillStyleType == (byte)FillStyleType.NonSmoothedRepeatingBitmap)
            {
                bitmapId = binaryReader.ReadUInt16();
                bitmapMatrix = new Matrix();
                bitmapMatrix.ReadData(binaryReader);
            }

            base.SetEndPoint(binaryReader);
        }

Usage Example

Exemple #1
0
        /// <summary>
        /// Reads the data.
        /// </summary>
        /// <param name="binaryReader">Binary reader.</param>
        /// <param name="shapeType">Shape type.</param>
        public void ReadData(BufferedBinaryReader binaryReader, ShapeType shapeType)
        {
            int count = 0;

            byte fillStyleCount = binaryReader.ReadByte();

            count = System.Convert.ToInt32(fillStyleCount);
            ushort fillStyleCountExtended = 0;

            if (fillStyleCount == 0xFF && (shapeType == ShapeType.Shape2 || shapeType == ShapeType.Shape3))
            {
                fillStyleCountExtended = binaryReader.ReadUInt16();
                count = System.Convert.ToInt32(fillStyleCountExtended);
            }

            if (count != 0)
            {
                for (int i = 0; i < count; i++)
                {
                    byte      fillStyleType = binaryReader.PeekByte();
                    FillStyle fillStyle     = GetFillStyleFromType(fillStyleType);
                    if (fillStyle != null)
                    {
                        fillStyle.ReadData(binaryReader, shapeType);
                        this.Add(fillStyle);
                    }
                }
            }
        }