Video ImageBlock class
Example #1
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);
                }
            }
        }
Example #2
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);
                }
            }
        }
Example #3
0
 /// <summary>
 /// Creates a new <see cref="ScreenVideoPacket"/> instance.
 /// </summary>
 /// <param name="blockWidth">Width of the block.</param>
 /// <param name="imageWidth">Width of the image.</param>
 /// <param name="blockHeight">Height of the block.</param>
 /// <param name="imageHeight">Height of the image.</param>
 /// <param name="blocks">Blocks.</param>
 public ScreenVideoPacket(int blockWidth, int imageWidth, 
     int blockHeight, int imageHeight, ImageBlock[] blocks)
 {
     this.blockWidth = blockWidth;
     this.blockHeight = blockHeight;
     this.imageWidth = imageWidth;
     this.imageHeight = imageHeight;
     this.blocks = blocks;
 }