当前位置: 首页>>代码示例>>C#>>正文


C# BufferedBinaryReader.ReadBytes方法代码示例

本文整理汇总了C#中SwfDotNet.IO.Utils.BufferedBinaryReader.ReadBytes方法的典型用法代码示例。如果您正苦于以下问题:C# BufferedBinaryReader.ReadBytes方法的具体用法?C# BufferedBinaryReader.ReadBytes怎么用?C# BufferedBinaryReader.ReadBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SwfDotNet.IO.Utils.BufferedBinaryReader的用法示例。


在下文中一共展示了BufferedBinaryReader.ReadBytes方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadData

        /// <summary>
        /// Reads the data from the binary reader.
        /// </summary>
        /// <param name="binaryReader">Binary reader.</param>
        public override void ReadData(BufferedBinaryReader binaryReader)
        {
            byte[] b = binaryReader.ReadBytes(4);
            BitArray ba = BitParser.GetBitValues(b);

            blockWidth = (int)BitParser.ReadUInt32(ba, 0, 4);
            imageWidth = (int)BitParser.ReadUInt32(ba, 4, 12);
            blockHeight = (int)BitParser.ReadUInt32(ba, 16, 4);
            imageHeight = (int)BitParser.ReadUInt32(ba, 20, 12);

            int nbWBlock = 0;
            int nbBlockWInt = imageWidth / blockWidth;
            float nbBlockWDec = imageWidth / blockWidth;
            if (nbBlockWInt == nbBlockWDec)
                nbWBlock = nbBlockWInt;
            else
                nbWBlock = nbBlockWInt + 1;

            int nbHBlock = 0;
            int nbBlockHInt = imageHeight / blockHeight;
            float nbBlockHDec = imageHeight / blockHeight;
            if (nbBlockHInt == nbBlockHDec)
                nbHBlock = nbBlockHInt;
            else
                nbHBlock = nbBlockHInt + 1;

            int nbBlock = nbWBlock * nbHBlock;

            if (nbBlock > 0)
            {
                blocks = new ImageBlock[nbBlock];

                for (int i = 0; i < nbBlock; i++)
                {
                    blocks[i] = new ImageBlock();
                    blocks[i].ReadData(binaryReader);
                }
            }
        }
开发者ID:foresightbrand,项目名称:brandqq,代码行数:43,代码来源:VideoPacket.cs

示例2: ReadData

        /// <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);
                }
            }
        }
开发者ID:Berenold,项目名称:SwfExport,代码行数:69,代码来源:DefineBitsLossLessTag.cs

示例3: ReadData

        /// <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 tl = System.Convert.ToInt32(rh.TagLength);
            jpegData = binaryReader.ReadBytes(tl);
        }
开发者ID:Berenold,项目名称:SwfExport,代码行数:11,代码来源:JpegTable.cs

示例4: ReadData

        /// <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();
        }
开发者ID:bladecoding,项目名称:SwfExport,代码行数:15,代码来源:ButtonCondaction.cs

示例5: ReadData

        /// <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);

            spriteId = binaryReader.ReadUInt16();
            int lenght = System.Convert.ToInt32(rh.TagLength-2);
            actionRecord = binaryReader.ReadBytes(lenght);
        }
开发者ID:foresightbrand,项目名称:brandqq,代码行数:12,代码来源:InitActionTag.cs

示例6: ReadData

        /// <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);
                }
            }
        }
开发者ID:wuzhen,项目名称:SwfDecompiler,代码行数:70,代码来源:DefineBitsLossLess2Tag.cs

示例7: ReadData

        /// <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();
        }
开发者ID:foresightbrand,项目名称:brandqq,代码行数:35,代码来源:DefineButtonTag.cs

示例8: ReadData

        /// <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 tl = System.Convert.ToInt32(rh.TagLength);
            characterId = binaryReader.ReadUInt16();
            int imgLen = Convert.ToInt32(binaryReader.ReadUInt32());
            if (imgLen > 0)
            {
                jpegData = binaryReader.ReadBytes(imgLen);
                alphaData = binaryReader.ReadBytes(tl - 6 - imgLen);
            }
        }
开发者ID:bladecoding,项目名称:SwfExport,代码行数:17,代码来源:DefineBitsJpeg3Tag.cs

示例9: ReadTag

        /// <summary>
        /// Read next tag from swf input stream.
        /// </summary>
        /// <param name="version">Version.</param>
        /// <param name="binaryReader">Binary reader.</param>
        /// <param name="tagList">Tag list.</param>
        /// <returns></returns>
        internal static BaseTag ReadTag(byte version, BufferedBinaryReader binaryReader, BaseTagCollection tagList)
        {
            long posBefore = binaryReader.BaseStream.Position;
            RecordHeader rh = new RecordHeader();
            rh.ReadData(binaryReader);

            int offset = (int)(binaryReader.BaseStream.Position - posBefore);
            binaryReader.BaseStream.Position = posBefore;

            BaseTag resTag = null;

            switch (rh.TagCode)
            {
                case (int)TagCodeEnum.DefineBits: resTag = new DefineBitsTag(); break;
                case (int)TagCodeEnum.DefineBitsJpeg2: resTag = new DefineBitsJpeg2Tag(); break;
                case (int)TagCodeEnum.DefineBitsJpeg3: resTag = new DefineBitsJpeg3Tag(); break;
                case (int)TagCodeEnum.DefineBitsLossLess: resTag = new DefineBitsLossLessTag(); break;
                case (int)TagCodeEnum.DefineBitsLossLess2: resTag = new DefineBitsLossLess2Tag(); break;
                case (int)TagCodeEnum.DefineButton: resTag = new DefineButtonTag(); break;
                case (int)TagCodeEnum.DefineButton2: resTag = new DefineButton2Tag(); break;
                case (int)TagCodeEnum.DefineButtonCxForm: resTag = new DefineButtonCxFormTag(); break;
                case (int)TagCodeEnum.DefineButtonSound: resTag = new DefineButtonSoundTag(); break;
                case (int)TagCodeEnum.DefineEditText: resTag = new DefineEditTextTag(); break;
                case (int)TagCodeEnum.DefineFont: resTag = new DefineFontTag(); break;
                case (int)TagCodeEnum.DefineFont2: resTag = new DefineFont2Tag(); break;
                case (int)TagCodeEnum.DefineFontInfo: resTag = new DefineFontInfoTag(); break;
                case (int)TagCodeEnum.DefineFontInfo2: resTag = new DefineFontInfo2Tag(); break;
                case (int)TagCodeEnum.DefineMorphShape: resTag = new DefineMorphShapeTag(); break;
                case (int)TagCodeEnum.DefineShape: resTag = new DefineShapeTag(); break;
                case (int)TagCodeEnum.DefineShape2: resTag = new DefineShape2Tag(); break;
                case (int)TagCodeEnum.DefineShape3: resTag = new DefineShape3Tag(); break;
                case (int)TagCodeEnum.DefineSound: resTag = new DefineSoundTag(); break;
                case (int)TagCodeEnum.DefineSprite: resTag = new DefineSpriteTag(); break;
                case (int)TagCodeEnum.DefineText: resTag = new DefineTextTag(); break;
                case (int)TagCodeEnum.DefineText2: resTag = new DefineText2Tag(); break;
                case (int)TagCodeEnum.DefineVideoStream: resTag = new DefineVideoStreamTag(); break;
                case (int)TagCodeEnum.DoAction: resTag = new DoActionTag(); break;
                case (int)TagCodeEnum.EnableDebugger: resTag = new EnableDebuggerTag(); break;
                case (int)TagCodeEnum.EnableDebugger2: resTag = new EnableDebugger2Tag(); break;
                case (int)TagCodeEnum.End: resTag = new EndTag(); break;
                case (int)TagCodeEnum.ExportAssets: resTag = new ExportAssetsTag(); break;
                case (int)TagCodeEnum.FrameLabel: resTag = new FrameLabelTag(); break;
                case (int)TagCodeEnum.ImportAssets: resTag = new ImportAssetsTag(); break;
                case (int)TagCodeEnum.InitAction: resTag = new InitActionTag(); break;
                case (int)TagCodeEnum.JpegTable: resTag = new JpegTableTag(); break;
                case (int)TagCodeEnum.PlaceObject: resTag = new PlaceObjectTag(); break;
                case (int)TagCodeEnum.PlaceObject2:	resTag = new PlaceObject2Tag(); break;
                case (int)TagCodeEnum.Protect: resTag = new ProtectTag(); break;
                case (int)TagCodeEnum.RemoveObject: resTag = new RemoveObjectTag(); break;
                case (int)TagCodeEnum.RemoveObject2: resTag = new RemoveObject2Tag(); break;
                case (int)TagCodeEnum.ScriptLimit: resTag = new ScriptLimitTag(); break;
                case (int)TagCodeEnum.SetBackgroundColor: resTag = new SetBackgroundColorTag(); break;
                case (int)TagCodeEnum.SetTabIndex: resTag = new SetTabIndexTag(); break;
                case (int)TagCodeEnum.ShowFrame: resTag = new ShowFrameTag(); break;
                case (int)TagCodeEnum.SoundStreamBlock: resTag = new SoundStreamBlockTag(); break;
                case (int)TagCodeEnum.SoundStreamHead: resTag = new SoundStreamHeadTag(); break;
                case (int)TagCodeEnum.SoundStreamHead2: resTag = new SoundStreamHead2Tag(); break;
                case (int)TagCodeEnum.StartSound: resTag = new StartSoundTag(); break;
                //TODO: Sorenson Codec
                case (int)TagCodeEnum.VideoFrame: resTag = ReadVideoFrameTag(binaryReader, tagList); break;
                default: resTag = new BaseTag(binaryReader.ReadBytes(System.Convert.ToInt32(rh.TagLength + offset))); break;
            }

            //Read the data of the current tag
            resTag.ReadData(version, binaryReader);

            //LOG
            long mustRead = rh.TagLength + offset;
            if (posBefore + mustRead != binaryReader.BaseStream.Position)
            {
                binaryReader.BaseStream.Position = posBefore + rh.TagLength + offset;
                if (log.IsErrorEnabled)
                    log.Error(Enum.GetName(TagCodeEnum.DefineBits.GetType(), rh.TagCode) + "....KO");
            }
            else if (log.IsInfoEnabled)
                log.Info(Enum.GetName(TagCodeEnum.DefineBits.GetType(), rh.TagCode) + "....OK (" + mustRead + ")");

            return resTag;
        }
开发者ID:foresightbrand,项目名称:brandqq,代码行数:86,代码来源:SwfReader.cs

示例10: ReadData

        /// <summary>
        /// Reads the data.
        /// </summary>
        /// <param name="reader">Reader.</param>
        /// <param name="bitmapColorTableSize">Size of the bitmap color table.</param>
        /// <param name="bitmapWidth">Width of the bitmap.</param>
        /// <param name="bitmapHeight">Height of the bitmap.</param>
        /// <param name="toRead">To read.</param>
        public void ReadData(BufferedBinaryReader reader, byte bitmapColorTableSize, 
			ushort bitmapWidth, ushort bitmapHeight, int toRead)
        {
            int size = ((bitmapColorTableSize + 1) * 3) + (bitmapWidth * bitmapHeight);
            byte[] uncompressed = new byte[size];

            byte[] compressed = reader.ReadBytes(toRead);
            Inflater zipInflator = 	new Inflater();
            zipInflator.SetInput(compressed);
            zipInflator.Inflate(uncompressed, 0, size);

            int readed = 0;
            int offset = size;

            colorTableRGB = new RGB[bitmapColorTableSize + 1];
            for (int i = 0; i < bitmapColorTableSize + 1; i++)
            {
                byte red = uncompressed[readed];
                readed++;
                byte green = uncompressed[readed];
                readed++;
                byte blue = uncompressed[readed];
                readed++;
                colorTableRGB[i] = new RGB(red, green, blue);
                offset -= 3;
            }

            colorMapPixelData = new byte[offset];
            for (int i = 0; i < offset; i++, readed++)
                colorMapPixelData[i] = uncompressed[readed];
        }
开发者ID:bladecoding,项目名称:SwfExport,代码行数:39,代码来源:ColorMap.cs

示例11: ReadData

        /// <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);

            bool placeFlagHasClipActions = binaryReader.ReadBoolean();
            bool placeFlagHasClipDepth = binaryReader.ReadBoolean();
            bool placeFlagHasName = binaryReader.ReadBoolean();
            bool placeFlagHasRatio = binaryReader.ReadBoolean();
            bool placeFlagHasColorTransform = binaryReader.ReadBoolean();
            bool placeFlagHasMatrix = binaryReader.ReadBoolean();
            bool placeFlagHasCharacter = binaryReader.ReadBoolean();
            placeFlagMove = binaryReader.ReadBoolean();

            depth = binaryReader.ReadUInt16();
            characterId = 0;
            if (placeFlagHasCharacter)
                characterId = binaryReader.ReadUInt16();
            matrix = null;
            if (placeFlagHasMatrix)
            {
                matrix = new Matrix();
                matrix.ReadData(binaryReader);
            }
            colorTransform = null;
            if (placeFlagHasColorTransform)
            {
                colorTransform = new CXFormWithAlphaData();
                colorTransform.ReadData(binaryReader);
            }
            ratio = 0;
            if (placeFlagHasRatio)
                ratio = binaryReader.ReadUInt16() / 65535.0f;
            name = null;
            if (placeFlagHasName)
                name = binaryReader.ReadString();
            clipDepth = 0;
            if (placeFlagHasClipDepth)
                clipDepth = binaryReader.ReadUInt16();

            // get bytecode actions
            clipActions = null;
            if (placeFlagHasClipActions)
            {
                // different behaviour for Flash 6+
                actionHead = (version>=6) ? binaryReader.ReadBytes(6) : binaryReader.ReadBytes(4);
                // read clip action records to list
                ArrayList clpAc = new ArrayList();
                //ClipActionRec a = null;
                bool res = true;
                do
                {
                    ClipActionRec action = new ClipActionRec();
                    res = action.ReadData(binaryReader, version);
                    if (res)
                        clpAc.Add(action);
                }
                while (res);
                // copy list to array
                clipActions = new ClipActionRec[clpAc.Count];
                clpAc.CopyTo(clipActions,0);
            }
        }
开发者ID:foresightbrand,项目名称:brandqq,代码行数:66,代码来源:PlaceObject2Tag.cs


注:本文中的SwfDotNet.IO.Utils.BufferedBinaryReader.ReadBytes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。