예제 #1
0
        /// <summary>
        /// Reads MatrixData from swf into a byte-array
        /// </summary>
        /// <remarks>
        /// Since were only interested in bytecode actions, theres no need to parse this data.
        /// </remarks>
        protected byte[] ReadMatrixData()
        {
            byte[]   b  = br.ReadBytes(27);          // max. byte size of matrix record
            BitArray ba = BitParser.GetBitValues(b);

            int bitcount = 1;
            int Nbits;

            if (ba[bitcount - 1])
            {
                Nbits     = (int)BitParser.ReadUInt32(ba, bitcount, 5);
                bitcount += 5 + Nbits * 2;
            }
            bitcount += 1;
            if (ba[bitcount - 1])
            {
                Nbits     = (int)BitParser.ReadUInt32(ba, bitcount, 5);
                bitcount += 5 + Nbits * 2;
            }
            Nbits     = (int)BitParser.ReadUInt32(ba, bitcount, 5);
            bitcount += 5 + Nbits * 2;
            int bytecount = Convert.ToInt32(Math.Ceiling((double)bitcount / 8.0));

            byte[] matrix = new byte[bytecount];
            for (int i = 0; i < bytecount; i++)
            {
                matrix[i] = b[i];
            }
            br.BaseStream.Position -= b.Length - bytecount;
            return(matrix);
        }
예제 #2
0
        /// <summary>
        /// Creates a new <see cref="Pix15"/> instance.
        /// </summary>
        /// <param name="bytes">Bytes.</param>
        public Pix15(byte[] bytes)
        {
            BitArray ba = BitParser.GetBitValues(bytes);

            this.red   = (byte)BitParser.ReadUInt32(ba, 1, 5);
            this.green = (byte)BitParser.ReadUInt32(ba, 6, 5);
            this.blue  = (byte)BitParser.ReadUInt32(ba, 11, 5);
        }
        private void ParseAttributes(BaseTag tag)
        {
            BitArray ba = BitParser.GetBitValues(tag.Data);

            FileAttributes.UseDirectBlit = (bool)ba[16 + 1];
            FileAttributes.UseGPU        = (bool)ba[16 + 2];
            FileAttributes.HasMetaData   = (bool)ba[16 + 3];
            FileAttributes.Actionscript3 = (bool)ba[16 + 4];
            FileAttributes.UseNetwork    = (bool)ba[16 + 7];
        }
예제 #4
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);
                }
            }
        }
예제 #5
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();
                }
            }
        }
예제 #6
0
        /// <summary>
        /// Reads RectData from swf into a byte-array.
        /// </summary>
        /// <remarks>
        /// Since were only interested in bytecode actions, theres no need to parse this data.
        /// </remarks>
        protected byte[] ReadRectData()
        {
            byte[]   b  = br.ReadBytes(17);          // max. byte size of rect record
            BitArray ba = BitParser.GetBitValues(b);

            int Nbits     = (int)BitParser.ReadUInt32(ba, 5);
            int bitcount  = 5 + Nbits * 4;
            int bytecount = Convert.ToInt32(Math.Ceiling((double)bitcount / 8.0));

            byte[] rect = new byte[bytecount];
            for (int i = 0; i < bytecount; i++)
            {
                rect[i] = b[i];
            }
            br.BaseStream.Position -= b.Length - bytecount;

            return(rect);
        }
예제 #7
0
        private Rectangle GetSwfRect(byte[] bytes)
        {
            BitArray ba    = BitParser.GetBitValues(bytes);
            int      Nbits = (int)BitParser.ReadUInt32(ba, 5);
            int      index = 5;
            int      xmin  = (int)BitParser.ReadUInt32(ba, index, Nbits) / 20;

            index += Nbits;
            int xmax = (int)BitParser.ReadUInt32(ba, index, Nbits) / 20;

            index += Nbits;
            int ymin = (int)BitParser.ReadUInt32(ba, index, Nbits) / 20;

            index += Nbits;
            int ymax = (int)BitParser.ReadUInt32(ba, index, Nbits) / 20;

            return(new Rectangle(xmin, ymin, xmax, ymax));
        }
예제 #8
0
        /// <summary>
        /// Reads RectData from swf into a byte-array
        /// </summary>
        /// <remarks>
        /// Since were only interested in bytecode actions, theres no need to parse this data.
        /// </remarks>
        protected byte[] ReadCXFormWithAlphaData()
        {
            byte[]   b  = br.ReadBytes(17);          // max. byte size of transform record
            BitArray ba = BitParser.GetBitValues(b);

            bool hasAdd  = ba[0];
            bool hasMult = ba[1];

            int Nbits    = (int)BitParser.ReadUInt32(ba, 2, 4);
            int bitcount = 6 + (hasAdd ? Nbits * 4 : 0) + (hasMult ? Nbits * 4 : 0);

            int bytecount = Convert.ToInt32(Math.Ceiling((double)bitcount / 8.0));

            byte[] cfa = new byte[bytecount];
            for (int i = 0; i < bytecount; i++)
            {
                cfa[i] = b[i];
            }
            br.BaseStream.Position -= b.Length - bytecount;
            return(cfa);
        }
예제 #9
0
        /// <summary>
        /// Reads the data.
        /// </summary>
        /// <param name="binaryReader">Binary reader.</param>
        /// <param name="firstByte">First byte.</param>
        /// <param name="buttonType">Button type.</param>
        public void ReadData(BufferedBinaryReader binaryReader,
                             byte firstByte, TagCodeEnum buttonType)
        {
            BitArray ba = BitParser.GetBitValues(new byte[1] {
                firstByte
            });

            buttonStateHitTest = ba.Get(4);
            buttonStateDown    = ba.Get(5);
            buttonStateOver    = ba.Get(6);
            buttonStateUp      = ba.Get(7);

            characterId = binaryReader.ReadUInt16();
            placeDepth  = binaryReader.ReadUInt16();
            placeMatrix = new Matrix();
            placeMatrix.ReadData(binaryReader);
            colorTransform = null;

            if (buttonType == TagCodeEnum.DefineButton2)
            {
                colorTransform = new CXFormWithAlphaData();
                colorTransform.ReadData(binaryReader);
            }
        }
예제 #10
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();
            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();
            }
        }