BufferedBinaryReader. This class extends a binaryReader to provide the way to read bit per bit a binary stream. This class use a buffer to do it. ATTENTION: By default, this class works with the LittleEndian mode (for x86).
Inheritance: System.IO.BinaryReader
Esempio n. 1
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);

            int tl = System.Convert.ToInt32(rh.TagLength);
            Meta = binaryReader.ReadString();
        }
Esempio n. 2
0
        /// <summary>
        /// Reads the data.
        /// </summary>
        /// <param name="binaryReader">Binary reader.</param>
        public override void ReadData(BufferedBinaryReader binaryReader)
        {
            uint pictureStartCode = binaryReader.ReadUBits(17);
            uint version = binaryReader.ReadUBits(5);
            uint temporalRef = binaryReader.ReadUBits(8);

            //TODO...
        }
Esempio n. 3
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();
            }
        }
Esempio n. 4
0
        /// <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);
            }
        }
Esempio n. 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)
        {
            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);
                    }
                }
            }
        }
Esempio n. 6
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();
            }
        }
Esempio n. 7
0
 /// <summary>
 /// Reads the data.
 /// </summary>
 /// <param name="binaryReader">Binary reader.</param>
 public abstract void ReadData(BufferedBinaryReader binaryReader);
Esempio n. 8
0
 /// <summary>
 /// Reads the data for the swf decompilation.
 /// </summary>
 /// <param name="version">Version.</param>
 /// <param name="binaryReader">Binary reader.</param>
 public virtual void ReadData(byte version, BufferedBinaryReader binaryReader)
 {
 }
Esempio n. 9
0
        /// <summary>
        /// Reads the data.
        /// </summary>
        /// <param name="binaryReader">Binary reader.</param>
        /// <param name="flags">Flags.</param>
        public void ReadData(BufferedBinaryReader binaryReader, byte flags)
        {
            base.SetStartPoint(binaryReader);
            byte numBits = (byte)(flags & 0x0F);
            bool generalLineFLag = binaryReader.ReadBoolean();
            deltaX = 0;
            deltaY = 0;

            if (generalLineFLag)
            {
                deltaX = binaryReader.ReadSBits((uint)(numBits + 2));
                deltaY = binaryReader.ReadSBits((uint)(numBits + 2));
            }
            else
            {
                bool vertLineFlag = binaryReader.ReadBoolean();
                if (!vertLineFlag)
                    deltaX = binaryReader.ReadSBits((uint)(numBits + 2));
                else
                    deltaY = binaryReader.ReadSBits((uint)(numBits + 2));
            }
            base.SetEndPoint(binaryReader);
        }
Esempio n. 10
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();
 }
Esempio n. 11
0
        /// <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);
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Inits the stream reading process.
        /// </summary>
        /// <param name="path">Path.</param>
        /// <param name="useBuffer">Use buffer.</param>
        private void Init(string path, bool useBuffer)
        {
            Stream stream = File.OpenRead(path);
            if (useBuffer)
            {
                FileInfo fi = new FileInfo(path);

                byte[] buff = new byte[fi.Length];
                stream.Read(buff, 0, System.Convert.ToInt32(fi.Length));
                stream.Close();

                MemoryStream ms = new MemoryStream(buff);
                this.br = new BufferedBinaryReader(ms, false);
            }
            else
            {
                this.br = new BufferedBinaryReader(stream, false);
            }
        }
Esempio n. 13
0
 /// <summary>
 /// Creates a new <see cref="FlvReader"/> instance.
 /// </summary>
 /// <param name="stream">Stream.</param>
 public FlvReader(Stream stream)
 {
     this.br = new BufferedBinaryReader(stream, false);
 }
Esempio n. 14
0
 /// <summary>
 /// Reads the data.
 /// </summary>
 /// <param name="binaryReader">Binary reader.</param>
 /// <param name="numGlyphs">Num glyphs.</param>
 public void ReadData(BufferedBinaryReader binaryReader, ushort numGlyphs)
 {
     Clear();
     for (int i = 0; i < numGlyphs; i++)
     {
         binaryReader.SynchBits();
         Rect fontBound = new Rect();
         fontBound.ReadData(binaryReader);
         Add(fontBound);
     }
 }
Esempio n. 15
0
        /// <summary>
        /// Reads the data from a binary file
        /// </summary>
        /// <param name="binaryReader">Binary reader.</param>
        public void ReadData(BufferedBinaryReader binaryReader)
        {
            base.SetStartPoint(binaryReader);

            uint nBits = binaryReader.ReadUBits(5);
            xMin = binaryReader.ReadSBits(nBits);
            xMax = binaryReader.ReadSBits(nBits);
            yMin = binaryReader.ReadSBits(nBits);
            yMax = binaryReader.ReadSBits(nBits);

            base.SetEndPoint(binaryReader);
        }
Esempio n. 16
0
        /// <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);
                    }
                }
            }
        }
Esempio n. 17
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);

            characterId = binaryReader.ReadUInt16();
            binaryReader.SynchBits();

            startBounds = new Rect();
            startBounds.ReadData(binaryReader);

            binaryReader.SynchBits();
            endBounds = new Rect();
            endBounds.ReadData(binaryReader);
            binaryReader.SynchBits();

            offset = binaryReader.ReadUInt32();

            morphFillStyles = new MorphFillStyleCollection();
            morphFillStyles.ReadData(binaryReader);

            morphLineStyles = new MorphLineStyleCollection();
            morphLineStyles.ReadData(binaryReader);

            ShapeWithStyle.NumFillBits = (uint)morphFillStyles.Count;
            ShapeWithStyle.NumLineBits = (uint)morphLineStyles.Count;

            startEdges = new ShapeRecordCollection();
            startEdges.ReadData(binaryReader, ShapeType.None);

            ShapeWithStyle.NumFillBits = (uint)morphFillStyles.Count;
            ShapeWithStyle.NumLineBits = (uint)morphLineStyles.Count;

            endEdges = new ShapeRecordCollection();
            endEdges.ReadData(binaryReader, ShapeType.None);
        }
Esempio n. 18
0
 /// <summary>
 /// Reads the data.
 /// </summary>
 /// <param name="binaryReader">Binary reader.</param>
 public void ReadData(BufferedBinaryReader binaryReader)
 {
     base.SetStartPoint(binaryReader);
     binaryReader.SynchBits();
     bool hasScale = binaryReader.ReadBoolean();
     if (hasScale)
     {
         uint nScaleBits = binaryReader.ReadUBits(5);
         matrix[0, 0] = binaryReader.ReadFloat(nScaleBits);
         matrix[1, 1] = binaryReader.ReadFloat(nScaleBits);
     }
     bool hasRotate = binaryReader.ReadBoolean();
     if (hasRotate)
     {
         uint nRotateBits = binaryReader.ReadUBits(5);
         matrix[1, 0] = binaryReader.ReadFloat(nRotateBits);
         matrix[0, 1] = binaryReader.ReadFloat(nRotateBits);
     }
     uint nTranslateBits = binaryReader.ReadUBits(5);
     matrix[0, 2] = (float)binaryReader.ReadSBits(nTranslateBits);
     matrix[1, 2] = (float)binaryReader.ReadSBits(nTranslateBits);
     binaryReader.SynchBits();
     base.SetEndPoint(binaryReader);
 }
Esempio n. 19
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();
        }
Esempio n. 20
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);

            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);
            }
        }
Esempio n. 21
0
 /// <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);
 }
Esempio n. 22
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);
 }
Esempio n. 23
0
        /// <summary>
        /// Reads the data.
        /// </summary>
        /// <param name="binaryReader">Binary reader.</param>
        /// <param name="flags">Flags.</param>
        public void ReadData(BufferedBinaryReader binaryReader, byte flags)
        {
            base.SetStartPoint(binaryReader);
            byte numBits = (byte)(flags & 0x0F);

            controlDeltaX = binaryReader.ReadSBits((uint)(numBits + 2));
            controlDeltaY = binaryReader.ReadSBits((uint)(numBits + 2));
            anchorDeltaX = binaryReader.ReadSBits((uint)(numBits + 2));
            anchorDeltaY = binaryReader.ReadSBits((uint)(numBits + 2));
            base.SetEndPoint(binaryReader);
        }
Esempio n. 24
0
        /// <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();
        }
Esempio n. 25
0
        /// <summary>
        /// Reads the data.
        /// </summary>
        /// <param name="binaryReader">Binary reader.</param>
        /// <param name="flags">Flags.</param>
        /// <param name="numFillBits">Num fill bits.</param>
        /// <param name="numLineBits">Num line bits.</param>
        /// <param name="shapeType">Shape type.</param>
        public void ReadData(BufferedBinaryReader binaryReader, byte flags,
            ref byte numFillBits, ref byte numLineBits, ShapeType shapeType)
        {
            base.SetStartPoint(binaryReader);
            bool stateNewStyle = ((flags & 0x10) != 0);
            bool stateLineStyle = ((flags & 0x08) != 0);
            bool stateFillStyle1 = ((flags & 0x04) != 0);
            bool stateFillStyle0 = ((flags & 0x02) != 0);
            bool stateMoveTo = ((flags & 0x01) != 0);

            if  (stateMoveTo)
            {
                uint bits = binaryReader.ReadUBits(5);
                moveDeltaX = binaryReader.ReadSBits(bits);
                moveDeltaY = binaryReader.ReadSBits(bits);
            }
            if (stateFillStyle0)
            {
                fillStyle0 = (int)binaryReader.ReadUBits(numFillBits);
            }
            if (stateFillStyle1)
            {
                fillStyle1 = (int)binaryReader.ReadUBits(numFillBits);
            }
            if (stateLineStyle)
            {
                lineStyle = (int)binaryReader.ReadUBits(numLineBits);
            }

            fillStyles = null;
            lineStyles = null;

            if (stateNewStyle)
            {
                fillStyles = new FillStyleCollection();
                fillStyles.ReadData(binaryReader, shapeType);
                lineStyles = new LineStyleCollection();
                lineStyles.ReadData(binaryReader, shapeType);

                numFillBits = (byte)binaryReader.ReadUBits(4);
                numLineBits = (byte)binaryReader.ReadUBits(4);
            }
            base.SetEndPoint(binaryReader);
        }
Esempio n. 26
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);

            recursion = binaryReader.ReadUInt16();
            timeout = binaryReader.ReadUInt16();
        }
Esempio n. 27
0
        /// <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);
                }
            }
        }
Esempio n. 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);

            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);
        }
Esempio n. 29
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);

            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);
                }
            }
        }
Esempio n. 30
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)
        {
            RecordHeader rh = new RecordHeader();
            rh.ReadData(binaryReader);

            ushort count = binaryReader.ReadUInt16();
            exportedCharacters.Clear();
            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    Assert exportedCharacter = new Assert();
                    exportedCharacter.ReadData(binaryReader);
                    this.exportedCharacters.Add(exportedCharacter);
                }
            }
        }