GetBytes() public method

Converts the given signed rational number to an array of bytes.
public GetBytes ( Rational value ) : byte[]
value Rational /// The containing the numerator and denominator. ///
return byte[]
            public void ThenShouldReturnBytesGivenComputerArchitectureIsLittleEndian()
            {
                // Arrange
                var converter = new ExifBitConverter(new LittleEndianComputerArchitectureInfoFake());

                // Act
                var bytes = converter.GetBytes("Hello", false);

                // Assert
                Assert.That(bytes, Is.EqualTo(new[] { 0x48, 0x65, 0x6c, 0x6c, 0x6f }));
            }
            public void ThenShouldReturnReversedBytesBeginningWithNullGivenComputerArchitectureIsBigEndianAndAddNullTrue()
            {
                // Arrange
                var converter = new ExifBitConverter(new BigEndianComputerArchitectureInfoFake());

                // Act
                var bytes = converter.GetBytes("Hello", true);

                // Assert
                Assert.That(bytes, Is.EqualTo(new[] { 0x0, 0x6f, 0x6c, 0x6c, 0x65, 0x48 }));
            }
Esempio n. 3
0
 /// <summary>
 /// Sets a property item with the given id to the collection within the current
 /// <see cref="ImageFactory"/> instance.
 /// </summary>
 /// <param name="imageFactory">The image factory.</param>
 /// <param name="id">The id to assign to the property item.</param>
 /// <param name="value">The value to assign to the property item.</param>
 /// <returns>
 /// The <see cref="ImageFactory"/>.
 /// </returns>
 public static ImageFactory SetPropertyItem(this ImageFactory imageFactory, ExifPropertyTag id, string value)
 {
     // TODO: Cover the different encoding types for different tags.
     byte[] bytes = BitConverter.GetBytes(value);
     return(imageFactory.SetPropertyItem(id, ExifPropertyTagType.ASCII, bytes.Length, bytes));
 }