public void SetBitsTestIndexTooSmall()
 {
     ReportStart();
     try
     {
         _pf.SetBits(-1, 4, 6);
     }
     catch (ArgumentOutOfRangeException ex)
     {
         string message
             = "Start index must be between 0 and 7. Supplied index: -1";
         Assert.AreEqual("startIndex", ex.ParamName);
         StringAssert.Contains(message, ex.Message);
         ReportEnd();
         throw;
     }
 }
        /// <summary>
        /// Writes this component to the supplied output stream.
        /// </summary>
        /// <param name="outputStream">
        /// The output stream to write to.
        /// </param>
        public override void WriteToStream(Stream outputStream)
        {
            // logical screen size
            WriteShort(_screenSize.Width, outputStream);
            WriteShort(_screenSize.Height, outputStream);

            // Packed fields
            PackedFields packed = new PackedFields();

            packed.SetBit(0, _hasGlobalColourTable);
            packed.SetBits(1, 3, _colourResolution);
            packed.SetBit(4, _gctIsSorted);
            packed.SetBits(5, 3, _gctSizeBits);
            WriteByte(packed.Byte, outputStream);

            WriteByte(_backgroundColourIndex, outputStream);
            WriteByte(_pixelAspectRatio, outputStream);
        }
        /// <summary>
        /// Writes this component to the supplied output stream.
        /// </summary>
        /// <param name="outputStream">
        /// The output stream to write to.
        /// </param>
        public override void WriteToStream(Stream outputStream)
        {
            WriteByte(_blockSize, outputStream);

            PackedFields packed = new PackedFields();

            packed.SetBits(3, 3, (int)_disposalMethod);
            packed.SetBit(6, _expectsUserInput);
            packed.SetBit(7, _hasTransparentColour);
            WriteByte(packed.Byte, outputStream);

            WriteShort(_delayTime, outputStream);
            WriteByte(_transparentColourIndex, outputStream);
            WriteByte(0, outputStream); // block terminator
        }
Example #4
0
        /// <summary>
        /// Writes this component to the supplied output stream.
        /// </summary>
        /// <param name="outputStream">
        /// The output stream to write to.
        /// </param>
        public override void WriteToStream(Stream outputStream)
        {
            // Position and size of the image in this frame
            WriteShort(_position.X, outputStream);
            WriteShort(_position.Y, outputStream);
            WriteShort(_size.Width, outputStream);
            WriteShort(_size.Height, outputStream);

            PackedFields packed = new PackedFields();

            packed.SetBit(0, _hasLocalColourTable);
            packed.SetBit(1, _isInterlaced);
            packed.SetBit(2, _isSorted);
            packed.SetBits(5, 3, _localColourTableSizeBits);
            WriteByte(packed.Byte, outputStream);
        }
 public void GetSetBitsTest()
 {
     ReportStart();
     _pf = new PackedFields();
     _pf.SetBits(2, 3, 4);
     Assert.AreEqual(false, _pf.GetBit(0));
     Assert.AreEqual(false, _pf.GetBit(1));
     Assert.AreEqual(true, _pf.GetBit(2));
     Assert.AreEqual(false, _pf.GetBit(3));
     Assert.AreEqual(false, _pf.GetBit(4));
     Assert.AreEqual(false, _pf.GetBit(5));
     Assert.AreEqual(false, _pf.GetBit(6));
     Assert.AreEqual(false, _pf.GetBit(7));
     Assert.AreEqual(4, _pf.GetBits(2, 3));
     Assert.AreEqual(4, _pf.GetBits(1, 4));
     Assert.AreEqual(4, _pf.GetBits(0, 5));
     Assert.AreEqual(8, _pf.GetBits(0, 6));
     Assert.AreEqual(16, _pf.GetBits(0, 7));
     Assert.AreEqual(32, _pf.GetBits(0, 8));
     Assert.AreEqual(32, _pf.Byte);
     ReportEnd();
 }
 public void GetSetBitsTest2()
 {
     ReportStart();
     _pf = new PackedFields();
     _pf.SetBits(1, 5, 13);
     Assert.AreEqual(false, _pf.GetBit(0));
     Assert.AreEqual(false, _pf.GetBit(1));
     Assert.AreEqual(true, _pf.GetBit(2));
     Assert.AreEqual(true, _pf.GetBit(3));
     Assert.AreEqual(false, _pf.GetBit(4));
     Assert.AreEqual(true, _pf.GetBit(5));
     Assert.AreEqual(false, _pf.GetBit(6));
     Assert.AreEqual(false, _pf.GetBit(7));
     Assert.AreEqual(13, _pf.GetBits(1, 5));
     Assert.AreEqual(13, _pf.GetBits(0, 6));
     Assert.AreEqual(13, _pf.GetBits(2, 4));
     Assert.AreEqual(26, _pf.GetBits(1, 6));
     Assert.AreEqual(13, _pf.GetBits(0, 6));
     Assert.AreEqual(26, _pf.GetBits(0, 7));
     Assert.AreEqual(52, _pf.GetBits(0, 8));
     Assert.AreEqual(52, _pf.Byte);
     ReportEnd();
 }
		/// <summary>
		/// Writes this component to the supplied output stream.
		/// </summary>
		/// <param name="outputStream">
		/// The output stream to write to.
		/// </param>
		public override void WriteToStream( Stream outputStream )
		{
			WriteByte( _blockSize, outputStream );
			
			PackedFields packed = new PackedFields();
			packed.SetBits( 3, 3, (int) _disposalMethod );
			packed.SetBit( 6, _expectsUserInput );
			packed.SetBit( 7, _hasTransparentColour );
			WriteByte( packed.Byte, outputStream );
			
			WriteShort( _delayTime , outputStream);
			WriteByte( _transparentColourIndex, outputStream );
			WriteByte( 0, outputStream ); // block terminator
		}
        /// <summary>
        /// Writes this component to the supplied output stream.
        /// </summary>
        /// <param name="outputStream">
        /// The output stream to write to.
        /// </param>
        public override void WriteToStream( Stream outputStream )
        {
            // logical screen size
            WriteShort( _screenSize.Width, outputStream );
            WriteShort( _screenSize.Height, outputStream );

            // Packed fields
            PackedFields packed = new PackedFields();
            packed.SetBit( 0, _hasGlobalColourTable );
            packed.SetBits( 1, 3, _colourResolution );
            packed.SetBit( 4, _gctIsSorted );
            packed.SetBits( 5, 3, _gctSizeBits );
            WriteByte( packed.Byte, outputStream );

            WriteByte( _backgroundColourIndex, outputStream );
            WriteByte( _pixelAspectRatio, outputStream );
        }
Example #9
0
		/// <summary>
		/// Writes this component to the supplied output stream.
		/// </summary>
		/// <param name="outputStream">
		/// The output stream to write to.
		/// </param>
		public override void WriteToStream( Stream outputStream )
		{
			// Position and size of the image in this frame
			WriteShort( _position.X, outputStream );
			WriteShort( _position.Y, outputStream );
			WriteShort( _size.Width, outputStream );
			WriteShort( _size.Height, outputStream );
			
			PackedFields packed = new PackedFields();
			packed.SetBit( 0, _hasLocalColourTable );
			packed.SetBit( 1, _isInterlaced );
			packed.SetBit( 2, _isSorted );
			packed.SetBits( 5, 3, _localColourTableSizeBits );
			WriteByte( packed.Byte, outputStream );
		}