ReadByte() public méthode

Reads the byte.
public ReadByte ( ) : byte
Résultat byte
Exemple #1
0
        public override void ReadData(byte version, BufferedBinaryReader binaryReader)
        {
            base.ReadData(version, binaryReader);

            Type = (FlvScriptType)binaryReader.ReadUBits(8);

            int count = 0;
            if (Type == FlvScriptType.Number)
                count = 8;

            for (int i = 0; i < count; i++)
            {
                binaryReader.ReadByte();
            }
        }
Exemple #2
0
 /// <summary>
 /// Reads the data from the binary reader.
 /// </summary>
 /// <param name="binaryReader">Binary reader.</param>
 public virtual void ReadData(BufferedBinaryReader binaryReader)
 {
     this.red = binaryReader.ReadByte();
     this.green = binaryReader.ReadByte();
     this.blue = binaryReader.ReadByte();
 }
 /// <summary>
 /// Reads the data.
 /// </summary>
 /// <param name="binaryReader">Binary reader.</param>
 public void ReadData(BufferedBinaryReader binaryReader)
 {
     startRatio = binaryReader.ReadByte();
     startColor = new RGBA();
     startColor.ReadData(binaryReader);
     endRatio = binaryReader.ReadByte();
     endColor = new RGBA();
     endColor.ReadData(binaryReader);
 }
Exemple #4
0
        /// <summary>
        /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see>
        /// </summary>
        public override void ReadData(byte version, BufferedBinaryReader binaryReader)
        {
            RecordHeader rh = new RecordHeader();
            rh.ReadData(binaryReader);

            soundId = binaryReader.ReadUInt16();

            soundFormat = binaryReader.ReadUBits(4);
            soundRate = binaryReader.ReadUBits(2);
            soundSize = binaryReader.ReadUBits(1);
            soundType = binaryReader.ReadUBits(1);

            soundSampleCount = binaryReader.ReadUInt32();

            uint size = rh.TagLength - 2 - 1 - 4;
            soundData = new byte[size];
            for (uint i = 0; i < size; i++)
                soundData[i] = binaryReader.ReadByte();
        }
Exemple #5
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)
        {
            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);
        }
        /// <summary>
        /// Reads the data.
        /// </summary>
        /// <param name="binaryReader">Binary reader.</param>
        /// <param name="condActionSize">Size of the cond action.</param>
        public void ReadData(BufferedBinaryReader binaryReader, 
            ushort condActionSize)
        {
            int offset = condActionSize - 5;
            condO = binaryReader.ReadByte();
            condKey = binaryReader.ReadByte();

            actions = binaryReader.ReadBytes(offset);
            byte end = binaryReader.ReadByte();
        }
Exemple #7
0
 /// <summary>
 /// Reads the data.
 /// </summary>
 /// <param name="version">Version.</param>
 /// <param name="binaryReader">Binary reader.</param>
 public virtual void ReadData(byte version, BufferedBinaryReader binaryReader)
 {
     this.tagType = (FlvTagCodeEnum)binaryReader.ReadByte();
     this.dataSize = binaryReader.ReadUBits(24);
     this.timeStamp = binaryReader.ReadUBits(24);
     binaryReader.ReadUInt32();
 }
        /// <summary>
        /// Reads the data.
        /// </summary>
        /// <param name="binaryReader">Binary reader.</param>
        public void ReadData(BufferedBinaryReader binaryReader)
        {
            fillStyleType = binaryReader.ReadByte();

            startColor = null;
            endColor = null;
            if (fillStyleType == (byte)MorphFillStyleType.SolidFill)
            {
                startColor = new RGBA();
                startColor.ReadData(binaryReader);
                endColor = new RGBA();
                endColor.ReadData(binaryReader);
            }

            startGradientMatrix = null;
            endGradientMatrix = null;
            MorphGradientCollection gradient = null;
            if (fillStyleType == (byte)MorphFillStyleType.LinearGradientFill ||
                fillStyleType == (byte)MorphFillStyleType.RadialGradientFill)
            {
                startGradientMatrix = new Matrix();
                startGradientMatrix.ReadData(binaryReader);
                endGradientMatrix = new Matrix();
                endGradientMatrix.ReadData(binaryReader);
                gradient = new MorphGradientCollection();
                gradient.ReadData(binaryReader);
            }

            bitmapId = 0;
            startBitmapMatrix = null;
            endBitmapMatrix = null;
            if (fillStyleType == (byte)MorphFillStyleType.RepeatingBitmap ||
                fillStyleType == (byte)MorphFillStyleType.ClippedBitmapFill ||
                fillStyleType == (byte)MorphFillStyleType.NonSmoothedClippedBitmap ||
                fillStyleType == (byte)MorphFillStyleType.NonSmoothedRepeatingBitmap)
            {
                bitmapId = binaryReader.ReadUInt16();
                startBitmapMatrix = new Matrix();
                startBitmapMatrix.ReadData(binaryReader);
                endBitmapMatrix = new Matrix();
                endBitmapMatrix.ReadData(binaryReader);
            }
        }
        /// <summary>
        /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see>
        /// </summary>
        public override void ReadData(byte version, BufferedBinaryReader binaryReader)
        {
            RecordHeader rh = new RecordHeader();
            rh.ReadData(binaryReader);

            fontId = binaryReader.ReadUInt16();
            byte fontNameLen = binaryReader.ReadByte();
            fontName = binaryReader.ReadString(fontNameLen);

            binaryReader.ReadUBits(2); //reserved
            fontFlagsSmallText = binaryReader.ReadBoolean();
            binaryReader.ReadUBits(2); //not used
            fontFlagsItalic = binaryReader.ReadBoolean();
            fontFlagsBold = binaryReader.ReadBoolean();
            binaryReader.ReadBoolean(); //not used

            languageCode = binaryReader.ReadByte();

            long codeTableLenght = rh.TagLength - 5 - fontNameLen;
            codeTable = null;
            codeTable = new ushort[codeTableLenght];
            for (int i = 0; i < codeTableLenght / 2; i++)
                codeTable[i] = binaryReader.ReadUInt16();
        }
Exemple #10
0
        /// <summary>
        /// Reads the data.
        /// </summary>
        /// <param name="version">Version.</param>
        /// <param name="binaryReader">Binary reader.</param>
        public override void ReadData(byte version, BufferedBinaryReader binaryReader)
        {
            base.ReadData(version, binaryReader);
            this.soundFormat = (FlvSoundFormat)binaryReader.ReadUBits(4);
            this.soundRate = binaryReader.ReadUBits(2);
            this.isSnd16Bits = binaryReader.ReadBoolean();
            this.isStereo = binaryReader.ReadBoolean();

            uint dataLenght = this.dataSize - 1;
            if (dataLenght > 0)
            {
                this.soundData = new byte[dataLenght];
                for (int i = 0; i < dataLenght; i++)
                    this.soundData[i] = binaryReader.ReadByte();
            }
        }
        /// <summary>
        /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see>
        /// </summary>
        public override void ReadData(byte version, BufferedBinaryReader binaryReader)
        {
            RecordHeader rh = new RecordHeader();
            rh.ReadData(binaryReader);

            fontId = binaryReader.ReadUInt16();
            byte fontNameLen = binaryReader.ReadByte();
            fontName = binaryReader.ReadString(fontNameLen);

            binaryReader.ReadUBits(2); //reserved
            fontFlagsSmallText = binaryReader.ReadBoolean();
            fontFlagsShiftJIS = binaryReader.ReadBoolean();
            fontFlagsAINSI = binaryReader.ReadBoolean();
            fontFlagsItalic = binaryReader.ReadBoolean();
            fontFlagsBold = binaryReader.ReadBoolean();
            fontFlagsWildCodes = binaryReader.ReadBoolean();

            uint codeTableLenght = rh.TagLength - 4 - fontNameLen;

            if (!fontFlagsWildCodes)
            {
                codeTable = new uint[codeTableLenght];
                for (int i = 0; i < codeTableLenght; i++)
                    codeTable[i] = (uint)binaryReader.ReadByte();
            }
            else
            {
                codeTable = new uint[codeTableLenght / 2];
                for (int i = 0; i < codeTableLenght / 2; i++)
                    codeTable[i] = (uint)binaryReader.ReadUInt16();
            }
        }
        /// <summary>
        /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see>
        /// </summary>
        public override void ReadData(byte version, BufferedBinaryReader binaryReader)
        {
            RecordHeader rh = new RecordHeader();
            rh.ReadData(binaryReader);

            buttonId = binaryReader.ReadUInt16();
            characters = new ButtonRecordCollection();

            bool characterEndFlag = false;
            while (!characterEndFlag)
            {
                byte first = binaryReader.ReadByte();
                if (first == 0)
                    characterEndFlag = true;
                else
                {
                    ButtonRecord buttRecord = new ButtonRecord();
                    buttRecord.ReadData(binaryReader, first, TagCodeEnum.DefineButton);
                    characters.Add(buttRecord);
                }
            }

            int offset = 2;
            foreach (ButtonRecord butRec in characters)
                offset += butRec.GetSizeOf();

            int lenght = System.Convert.ToInt32(rh.TagLength) - offset - 1;
            //-1 for the ActionEndFlag
            actions = binaryReader.ReadBytes(lenght);
            //Read ActionEndFlag
            binaryReader.ReadByte();
        }
        /// <summary>
        /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see>
        /// </summary>
        public override void ReadData(byte version, BufferedBinaryReader binaryReader)
        {
            RecordHeader rh = new RecordHeader();
            rh.ReadData(binaryReader);

            characterId = binaryReader.ReadUInt16();
            rect = new Rect();
            rect.ReadData(binaryReader);

            BitArray ba = BitParser.GetBitValues(new byte[1]{ binaryReader.ReadByte() });

            bool hasText = ba.Get(0); //binaryReader.ReadBoolean();
            wordWrap = ba.Get(1); //binaryReader.ReadBoolean();
            multiline = ba.Get(2); //binaryReader.ReadBoolean();
            password = ba.Get(3); //binaryReader.ReadBoolean();
            readOnly = ba.Get(4); //binaryReader.ReadBoolean();
            bool hasTextColor = ba.Get(5); //binaryReader.ReadBoolean();
            bool hasMaxLength = ba.Get(6); //binaryReader.ReadBoolean();
            bool hasFont = ba.Get(7); //binaryReader.ReadBoolean();
            //binaryReader.SynchBits();

            ba = BitParser.GetBitValues(new byte[1]{ binaryReader.ReadByte() });
            //binaryReader.ReadBoolean(); //Reserved
            autoSize = ba.Get(1); //binaryReader.ReadBoolean();
            bool hasLayout = ba.Get(2); //binaryReader.ReadBoolean();
            noSelect = ba.Get(3); //binaryReader.ReadBoolean();
            border = ba.Get(4); //binaryReader.ReadBoolean();
            //binaryReader.ReadBoolean(); //Reserved
            html = ba.Get(6); //binaryReader.ReadBoolean();
            usedOutlines = ba.Get(7); //binaryReader.ReadBoolean();

            if (hasFont)
            {
                fontId = binaryReader.ReadUInt16();
                fontHeight = binaryReader.ReadUInt16();
            }

            if (hasTextColor)
            {
                textColor = new RGBA();
                textColor.ReadData(binaryReader);
            }

            if (hasMaxLength)
                maxLenght = binaryReader.ReadUInt16();

            if (hasLayout)
            {
                align = binaryReader.ReadByte();
                leftMargin = binaryReader.ReadUInt16();
                rightMargin = binaryReader.ReadUInt16();
                indent = binaryReader.ReadUInt16();
                leading = binaryReader.ReadUInt16();
            }

            variableName = binaryReader.ReadString();
            if (hasText)
                initialText = binaryReader.ReadString();
        }
Exemple #14
0
        /// <summary>
        /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see>
        /// </summary>
        public override void ReadData(byte version, BufferedBinaryReader binaryReader)
        {
            RecordHeader rh = new RecordHeader();
            rh.ReadData(binaryReader);

            fontId = binaryReader.ReadUInt16();

            bool fontFlagsHasLayout = binaryReader.ReadBoolean();
            fontFlagsShiftJIS = binaryReader.ReadBoolean();
            fontFlagsSmallText = binaryReader.ReadBoolean();
            fontFlagsANSI = binaryReader.ReadBoolean();
            bool fontFlagsWideOffsets = binaryReader.ReadBoolean();
            bool fontFlagsWideCodes = binaryReader.ReadBoolean();
            fontFlagsItalic = binaryReader.ReadBoolean();
            fontFlagsBold = binaryReader.ReadBoolean();
            languageCode = (LanguageCode)binaryReader.ReadByte();
            byte fontNameLength = binaryReader.ReadByte();

            fontName = binaryReader.ReadString(fontNameLength);

            ushort numGlyphs = binaryReader.ReadUInt16();

            if (numGlyphs > 0)
            {
                uint[] offsetTable = new uint[numGlyphs];
                for (int i = 0; i < numGlyphs; i++)
                {
                    if (fontFlagsWideOffsets)
                        offsetTable[i] = binaryReader.ReadUInt32();
                    else
                        offsetTable[i] = (uint)binaryReader.ReadUInt16();
                }
            }
            uint codeTableOffset = 0;
            if (fontFlagsWideOffsets)
                codeTableOffset = binaryReader.ReadUInt32();
            else
                codeTableOffset = (uint)binaryReader.ReadUInt16();

            if (numGlyphs > 0)
            {
                this.glyphShapesTable.IsWideCodes = fontFlagsWideCodes;
                this.glyphShapesTable.ReadData(binaryReader, numGlyphs);
            }

            if (fontFlagsHasLayout)
            {
                fontAscent = binaryReader.ReadInt16();
                fontDescent = binaryReader.ReadInt16();
                fontLeading = binaryReader.ReadInt16();

                if (numGlyphs > 0)
                {
                    fontAdvanceTable.ReadData(binaryReader, numGlyphs);
                    fontBoundsTable.ReadData(binaryReader, numGlyphs);
                    fontKerningTable.ReadData(binaryReader, fontFlagsWideCodes);
                }
            }
        }
        /// <summary>
        /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see>
        /// </summary>
        public override void ReadData(byte version, BufferedBinaryReader binaryReader)
        {
            RecordHeader rh = new RecordHeader();
            rh.ReadData(binaryReader);

            binaryReader.ReadByte();
            int lenght = System.Convert.ToInt32(rh.TagLength - 1);
            password = binaryReader.ReadString();
            //char[] password = br.ReadChars(lenght);
        }
 /// <summary>
 /// Reads the data.
 /// </summary>
 /// <param name="binaryReader">Binary reader.</param>
 /// <param name="fontFlagsWideCodes">Font flags wide codes.</param>
 public void ReadData(BufferedBinaryReader binaryReader, bool fontFlagsWideCodes)
 {
     this.fontFlagsWideCodes = fontFlagsWideCodes;
     if (fontFlagsWideCodes)
     {
         fontFlagsWideCode1 = (uint)binaryReader.ReadUInt16();
         fontFlagsWideCode2 = (uint)binaryReader.ReadUInt16();
     }
     else
     {
         fontFlagsWideCode1 = (uint)binaryReader.ReadByte();
         fontFlagsWideCode2 = (uint)binaryReader.ReadByte();
     }
     short fontKerningAdjustement = binaryReader.ReadInt16();
 }
Exemple #17
0
        /// <summary>
        /// Reads the data from a binary file
        /// </summary>
        /// <param name="binaryReader">Binary reader.</param>
        public void ReadData(BufferedBinaryReader binaryReader)
        {
            this.signature = binaryReader.ReadString(3);
            this.version = binaryReader.ReadByte();

            if (this.version > MAX_VERSION)
                throw new InvalidSwfVersionException(this.version, MAX_VERSION);

            this.fileSize = binaryReader.ReadUInt32();
            this.rect = new Rect();
            this.rect.ReadData(binaryReader);
            binaryReader.SynchBits();
            this.fps = binaryReader.ReadFloatWord(8, 8);
            this.frames = binaryReader.ReadUInt16();
        }
        /// <summary>
        /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see>
        /// </summary>
        public override void ReadData(byte version, BufferedBinaryReader binaryReader)
        {
            RecordHeader rh = new RecordHeader();
            rh.ReadData(binaryReader);

            uint max = rh.TagLength;
            if (version >= 6)
                max--;
            name = binaryReader.ReadString(max);
            if (version >= 6)
               binaryReader.ReadByte();
        }
        /// <summary>
        /// Reads the data.
        /// </summary>
        /// <param name="binaryReader">Binary reader.</param>
        public void ReadData(BufferedBinaryReader binaryReader)
        {
            uint count = 0;
            byte fillStyleCount = binaryReader.ReadByte();
            count = fillStyleCount;

            ushort fillStyleCountExtended = 0;
            if (fillStyleCount == 0xFF)
            {
                fillStyleCountExtended = binaryReader.ReadUInt16();
                count = fillStyleCountExtended;
            }

            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    byte fillStyleType = binaryReader.PeekByte();
                    MorphFillStyle morphFillStyle = GetMorphFillStyleFromType(fillStyleType);
                    if (morphFillStyle != null)
                    {
                        morphFillStyle.ReadData(binaryReader);
                        this.Add(morphFillStyle);
                    }
                }
            }
        }
Exemple #20
0
        /// <summary>
        /// Reads the data.
        /// </summary>
        /// <param name="binaryReader">Binary reader.</param>
        /// <param name="endOfRecordsFlag">End of records flag.</param>
        /// <param name="tagCodeEnum">Tag code enum.</param>
        public void ReadData(BufferedBinaryReader binaryReader, ref bool endOfRecordsFlag, 
            TagCodeEnum tagCodeEnum)
        {
            binaryReader.SynchBits();
            bool textRecordType = binaryReader.ReadBoolean();
            binaryReader.ReadUBits(3);

            bool styleFlagsHasFont = binaryReader.ReadBoolean();
            bool styleFlagsHasColor = binaryReader.ReadBoolean();
            bool styleFlagsHasYOffset = binaryReader.ReadBoolean();
            bool styleFlagsHasXOffset = binaryReader.ReadBoolean();

            if (textRecordType == false)
            {
                endOfRecordsFlag = true;
                return;
            }

            fontId = 0;
            if (styleFlagsHasFont)
                fontId = binaryReader.ReadUInt16();

            textColor = null;
            if (styleFlagsHasColor)
            {
                if (tagCodeEnum == TagCodeEnum.DefineText2)
                {
                    textColor = new RGBA();
                    textColor.ReadData(binaryReader);
                }
                else
                {
                    textColor = new RGB();
                    textColor.ReadData(binaryReader);
                }
            }

            xOffset = 0;
            if (styleFlagsHasXOffset)
                xOffset = binaryReader.ReadInt16();

            yOffset = 0;
            if (styleFlagsHasYOffset)
                yOffset = binaryReader.ReadInt16();

            textHeight = 0;
            if (styleFlagsHasFont)
                textHeight = binaryReader.ReadUInt16();

            byte glyphCount = binaryReader.ReadByte();
            if (glyphCount > 0)
            {
                if (glyphEntries == null)
                    glyphEntries = new GlyphEntryCollection();
                else
                    glyphEntries.Clear();

                for (int i = 0; i < glyphCount; i++)
                {
                    GlyphEntry glyphEntry = new GlyphEntry();
                    glyphEntry.ReadData(binaryReader);
                    glyphEntries.Add(glyphEntry);
                }
            }
        }
        /// <summary>
        /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see>
        /// </summary>
        public override void ReadData(byte version, BufferedBinaryReader binaryReader)
        {
            RecordHeader rh = new RecordHeader();
            rh.ReadData(binaryReader);

            long startPosition = binaryReader.BaseStream.Position;

            buttonId = binaryReader.ReadUInt16();
            binaryReader.ReadUBits(7); //reserved
            trackAsMenu = binaryReader.ReadBoolean();

            long startPos = binaryReader.BaseStream.Position;

            actionOffset = binaryReader.ReadUInt16();

            if (characters == null)
                characters = new ButtonRecordCollection();
            else
                characters.Clear();

            bool characterEndFlag = false;
            while (!characterEndFlag)
            {
                byte first = binaryReader.ReadByte();
                if (first == 0)
                    characterEndFlag = true;
                else
                {
                    ButtonRecord buttRecord = new ButtonRecord();
                    buttRecord.ReadData(binaryReader, first, TagCodeEnum.DefineButton2);
                    characters.Add(buttRecord);
                }
            }

            long curr = startPos + actionOffset;

            actions = new ButtonCondactionCollection();
            bool lastCondAction = false;
            if (actionOffset == 0)
                lastCondAction = true;

            while (!lastCondAction)
            {
                long readedBytes = binaryReader.BaseStream.Position - startPosition;
                ushort condActionSize = binaryReader.ReadUInt16();
                if (condActionSize == 0)
                {
                    lastCondAction = true;
                    condActionSize = (ushort)(rh.TagLength - readedBytes);
                }
                ButtonCondaction buttCond = new ButtonCondaction();
                buttCond.ReadData(binaryReader, condActionSize);
                actions.Add(buttCond);
            }
        }
        /// <summary>
        /// Reads the data.
        /// </summary>
        /// <param name="binaryReader">Binary reader.</param>
        /// <param name="numGlyphs">Num glyphs.</param>
        public void ReadData(BufferedBinaryReader binaryReader, ushort numGlyphs)
        {
            if (numGlyphs == 0)
                return;

            ShapeWithStyle.NumFillBits = 0;
            ShapeWithStyle.NumLineBits = 0;
            ShapeRecordCollection[] shapes = new ShapeRecordCollection[numGlyphs];
            for (int i = 0; i < numGlyphs; i++)
            {
                ShapeRecordCollection glyphShape = new ShapeRecordCollection();
                glyphShape.ReadData(binaryReader, ShapeType.None);
                shapes[i] = glyphShape;
            }

            for (int i = 0; i < numGlyphs; i++)
            {
                char c;
                if (isWideCodes)
                    c = (char)binaryReader.ReadUInt16();
                else
                    c = (char)binaryReader.ReadByte();
                this[c] = shapes[i];
            }
            shapes = null;
        }
        /// <summary>
        /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see>
        /// </summary>
        public override void ReadData(byte version, BufferedBinaryReader binaryReader)
        {
            RecordHeader rh = new RecordHeader();
            rh.ReadData(binaryReader);

            int beforePos = (int)binaryReader.BaseStream.Position;
            int toReaded = (int)rh.TagLength - 7;

            _characterId = binaryReader.ReadUInt16();
            _bitmapFormat = binaryReader.ReadByte();
            _bitmapWidth = binaryReader.ReadUInt16();
            _bitmapHeight = binaryReader.ReadUInt16();
            _bitmapColorTableSize = 0;

            if (_bitmapFormat == 3)
            {
                _bitmapColorTableSize = binaryReader.ReadByte();
                toReaded--;
            }

            if (_bitmapFormat == 3)
            {
                _colorMapData = new ColorMapData();
                _colorMapData.ReadData(binaryReader, _bitmapColorTableSize, _bitmapWidth, _bitmapHeight, toReaded);
            }
            else if (_bitmapFormat == 4 || _bitmapFormat == 5)
            {
                int imageSize = _bitmapWidth * _bitmapHeight;
                int uncompressedSize = imageSize;
                if (_bitmapFormat == 4)
                    uncompressedSize *= 2;
                else
                    uncompressedSize *= 4;

                byte[] uncompressed = new byte[uncompressedSize];
                byte[] compressed = binaryReader.ReadBytes(toReaded);
                Inflater zipInflator = 	new Inflater();
                zipInflator.SetInput(compressed);
                zipInflator.Inflate(uncompressed, 0, uncompressedSize);

                _bitmapColorData = null;
                if (_bitmapFormat == 4)
                {
                    Pix15[] bitmapPixelData = new Pix15[imageSize];
                    for (int i = 0, j = 0; i < imageSize; i++, j += 2)
                    {
                        byte[] data = new byte[2] {uncompressed[j], uncompressed[j+1]};
                        bitmapPixelData[i] = new Pix15(data);
                    }
                    _bitmapColorData = new BitmapColorData(bitmapPixelData);
                }
                else
                {
                    Pix24[] bitmapPixelData = new Pix24[imageSize];
                    for (int i = 0, j = 0; i < imageSize; i++, j += 4)
                    {
                        byte reserved = uncompressed[j];
                        byte red = uncompressed[j + 1];
                        byte green = uncompressed[j + 2];
                        byte blue = uncompressed[j + 3];
                        bitmapPixelData[i] = new Pix24(red, green, blue);
                    }
                    _bitmapColorData = new BitmapColorData(bitmapPixelData);
                }
            }
        }
        /// <summary>
        /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see>
        /// </summary>
        public override void ReadData(byte version, BufferedBinaryReader binaryReader)
        {
            RecordHeader rh = new RecordHeader();
            rh.ReadData(binaryReader);

            int beforePos = (int)binaryReader.BaseStream.Position;
            int toReaded = (int)rh.TagLength - 7;

            _characterId = binaryReader.ReadUInt16();
            _bitmapFormat = binaryReader.ReadByte();
            _bitmapWidth = binaryReader.ReadUInt16();
            _bitmapHeight = binaryReader.ReadUInt16();
            _bitmapColorTableSize = 0;

            if (_bitmapFormat == 3)
            {
                _bitmapColorTableSize = binaryReader.ReadByte();
                toReaded--;
            }

            int imageSize = _bitmapWidth * _bitmapHeight;

            if (_bitmapFormat == 3)
            {
                int uncompressedSize = imageSize + ((_bitmapColorTableSize + 1) * 4);
                byte[] uncompressed = new byte[uncompressedSize];
                byte[] compressed = binaryReader.ReadBytes(toReaded);
                Inflater zipInflator = 	new Inflater();
                zipInflator.SetInput(compressed);
                zipInflator.Inflate(uncompressed, 0, uncompressedSize);

                _alphaColorMapData = new AlphaColorMapData();
                _alphaColorMapData.ColorTableRgb = new RGBA[_bitmapColorTableSize + 1];
                int offset = 0;
                for (int i = 0; i < _bitmapColorTableSize + 1; i++, offset += 4)
                {
                    byte red = uncompressed[offset];
                    byte green = uncompressed[offset + 1];
                    byte blue = uncompressed[offset + 2];
                    byte alpha = uncompressed[offset + 3];
                    _alphaColorMapData.ColorTableRgb[i] = new RGBA(red, green, blue, alpha);
                }
                _alphaColorMapData.ColorMapPixelData = new byte[uncompressedSize - offset];
                for (int i = 0; i < uncompressedSize - offset; i++, offset++)
                    _alphaColorMapData.ColorMapPixelData[i] = uncompressed[offset];
            }
            else if (_bitmapFormat == 4 || _bitmapFormat == 5)
            {
                int uncompressedSize = imageSize * 4;
                byte[] uncompressed = new byte[uncompressedSize];
                byte[] compressed = binaryReader.ReadBytes(toReaded);
                Inflater zipInflator = 	new Inflater();
                zipInflator.SetInput(compressed);
                zipInflator.Inflate(uncompressed, 0, uncompressedSize);

                _alphaBitmapData = new AlphaBitmapData();
                _alphaBitmapData.BitmapPixelData = new RGBA[imageSize];
                for (int i = 0, j = 0; i < imageSize; i++, j += 4)
                {
                    byte red = uncompressed[j];
                    byte green = uncompressed[j + 1];
                    byte blue = uncompressed[j + 2];
                    byte alpha = uncompressed[j + 3];
                    _alphaBitmapData.BitmapPixelData[i] = new RGBA(red, green, blue, alpha);
                }
            }
        }
Exemple #25
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);
                    }
                }
            }
        }
        /// <summary>
        /// see <see cref="SwfDotNet.IO.Tags.BaseTag">base class</see>
        /// </summary>
        public override void ReadData(byte version, BufferedBinaryReader binaryReader)
        {
            RecordHeader rh = new RecordHeader();
            rh.ReadData(binaryReader);

            characterId = binaryReader.ReadUInt16();
            numFrames = binaryReader.ReadUInt16();
            width = binaryReader.ReadUInt16();
            height = binaryReader.ReadUInt16();
            binaryReader.ReadUBits(5);
            videoFlagsDeblocking = binaryReader.ReadUBits(2);
            videoFlagsSmoothing = binaryReader.ReadBoolean();
            codecId = binaryReader.ReadByte();
        }
        /// <summary>
        /// Reads the data.
        /// </summary>
        /// <param name="binaryReader">Binary reader.</param>
        public void ReadData(BufferedBinaryReader binaryReader)
        {
            byte numGradients = binaryReader.ReadByte();

            for (int i = 0; i < numGradients; i++)
            {
                MorphGradRecord morph = new MorphGradRecord();
                morph.ReadData(binaryReader);
                this.Add(morph);
            }
        }
Exemple #28
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)
 {
     base.SetStartPoint(binaryReader);
     ratio = binaryReader.ReadByte();
     color = null;
     if (shapeType == ShapeType.Shape3)
     {
         color = new RGBA();
         color.ReadData(binaryReader);
     }
     else if (shapeType == ShapeType.Shape || shapeType == ShapeType.Shape2)
     {
         color = new RGB();
         color.ReadData(binaryReader);
     }
     base.SetEndPoint(binaryReader);
 }
Exemple #29
0
        /// <summary>
        /// Reads the data from a binary reader.
        /// </summary>
        /// <param name="binaryReader">Binary reader.</param>
        public void ReadData(BufferedBinaryReader binaryReader)
        {
            byte[] b = binaryReader.ReadBytes(2);
            BitArray ba = BitParser.GetBitValues(b);

            dataSize = (int)BitParser.ReadUInt32(ba, 0, 16);

            data = null;
            if (dataSize != 0)
            {
                data = new byte[dataSize];
                for (int i = 0; i < dataSize; i++)
                    data[i] = binaryReader.ReadByte();
            }
        }
Exemple #30
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)
        {
            byte numGradients = binaryReader.ReadByte();

            if (numGradients > 0)
            {
                for (int i = 0; i < numGradients; i++)
                {
                    GradientRecord gradientRecords = new GradientRecord();
                    gradientRecords.ReadData(binaryReader, shapeType);
                    this.Add(gradientRecords);
                }
            }
        }