|
@@ -15,9 +15,9 @@ namespace WMFConverter.IO
|
|
|
|
|
|
private System.IO.Stream _inputStream;
|
|
private System.IO.Stream _inputStream;
|
|
private bool _isLittleEndian = BitConverter.IsLittleEndian;
|
|
private bool _isLittleEndian = BitConverter.IsLittleEndian;
|
|
-
|
|
|
|
- private byte[] _buf = new byte[4];
|
|
|
|
- private int _count = 0;
|
|
|
|
|
|
+
|
|
|
|
+ private byte[] _buf = new byte[4];
|
|
|
|
+ private int _count = 0;
|
|
|
|
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
@@ -47,23 +47,23 @@ namespace WMFConverter.IO
|
|
/// Create a DataInput instance using native order.
|
|
/// Create a DataInput instance using native order.
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="inputStream"></param>
|
|
/// <param name="inputStream"></param>
|
|
- public DataInput(System.IO.Stream inputStream)
|
|
|
|
|
|
+ public DataInput(System.IO.Stream inputStream)
|
|
{
|
|
{
|
|
_isLittleEndian = BitConverter.IsLittleEndian;
|
|
_isLittleEndian = BitConverter.IsLittleEndian;
|
|
- _inputStream = inputStream;
|
|
|
|
- }
|
|
|
|
|
|
+ _inputStream = inputStream;
|
|
|
|
+ }
|
|
|
|
|
|
- /// <summary>
|
|
|
|
- /// Default contructor.
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Default contructor.
|
|
/// Create a DataInput instance receving the order.
|
|
/// Create a DataInput instance receving the order.
|
|
- /// </summary>
|
|
|
|
- /// <param name="inputStream"></param>
|
|
|
|
- /// <param name="endian"></param>
|
|
|
|
- public DataInput(System.IO.Stream inputStream, bool endian)
|
|
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="inputStream"></param>
|
|
|
|
+ /// <param name="endian"></param>
|
|
|
|
+ public DataInput(System.IO.Stream inputStream, bool endian)
|
|
{
|
|
{
|
|
- _inputStream = inputStream;
|
|
|
|
|
|
+ _inputStream = inputStream;
|
|
_isLittleEndian = endian;
|
|
_isLittleEndian = endian;
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
@@ -73,152 +73,154 @@ namespace WMFConverter.IO
|
|
/// Reads the next one byte of this input stream as a signed 8-bit integer.
|
|
/// Reads the next one byte of this input stream as a signed 8-bit integer.
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
- public int ReadByte()
|
|
|
|
|
|
+ public int ReadByte()
|
|
{
|
|
{
|
|
- if (_inputStream.Read(_buf, 0, 1) == 1)
|
|
|
|
|
|
+ if (_inputStream.Read(_buf, 0, 1) == 1)
|
|
{
|
|
{
|
|
- _count += 1;
|
|
|
|
- return (0xff & _buf[0]);
|
|
|
|
- }
|
|
|
|
- throw new System.IO.EndOfStreamException();
|
|
|
|
- }
|
|
|
|
|
|
+ _count += 1;
|
|
|
|
+ return (0xff & _buf[0]);
|
|
|
|
+ }
|
|
|
|
+ throw new System.IO.EndOfStreamException();
|
|
|
|
+ }
|
|
|
|
|
|
- /// <summary>
|
|
|
|
|
|
+ /// <summary>
|
|
/// Reads the next two bytes of this input stream as a signed 16-bit integer.
|
|
/// Reads the next two bytes of this input stream as a signed 16-bit integer.
|
|
- /// </summary>
|
|
|
|
- /// <returns></returns>
|
|
|
|
- public int ReadInt16()
|
|
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ public int ReadInt16()
|
|
{
|
|
{
|
|
- if (_inputStream.Read(_buf, 0, 2) == 2)
|
|
|
|
|
|
+ if (_inputStream.Read(_buf, 0, 2) == 2)
|
|
{
|
|
{
|
|
- short value = 0;
|
|
|
|
- if (_isLittleEndian==false)
|
|
|
|
|
|
+ short value = 0;
|
|
|
|
+ if (_isLittleEndian == false)
|
|
|
|
+ {
|
|
|
|
+ value |= (short)(0xff & _buf[1]);
|
|
|
|
+ value |= (short)((0xff & _buf[0]) << 8);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
{
|
|
{
|
|
- value |= (short)(0xff & _buf[1]);
|
|
|
|
- value |= (short)((0xff & _buf[0]) << 8);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- value |= (short)(0xff & _buf[0]);
|
|
|
|
- value |= (short)((0xff & _buf[1]) << 8);
|
|
|
|
- }
|
|
|
|
- _count += 2;
|
|
|
|
- return value;
|
|
|
|
- }
|
|
|
|
- throw new System.IO.EndOfStreamException();
|
|
|
|
- }
|
|
|
|
|
|
+ value |= (short)(0xff & _buf[0]);
|
|
|
|
+ value |= (short)((0xff & _buf[1]) << 8);
|
|
|
|
+ }
|
|
|
|
+ _count += 2;
|
|
|
|
+ return value;
|
|
|
|
+ }
|
|
|
|
+ throw new System.IO.EndOfStreamException();
|
|
|
|
+ }
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Reads the next four bytes of this input stream as a signed 32-bit integer.
|
|
/// Reads the next four bytes of this input stream as a signed 32-bit integer.
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
- public int ReadInt32()
|
|
|
|
|
|
+ public int ReadInt32()
|
|
{
|
|
{
|
|
- if (_inputStream.Read(_buf, 0, 4) == 4)
|
|
|
|
|
|
+ if (_inputStream.Read(_buf, 0, 4) == 4)
|
|
{
|
|
{
|
|
- int value = 0;
|
|
|
|
- if (_isLittleEndian==false)
|
|
|
|
|
|
+ int value = 0;
|
|
|
|
+ if (_isLittleEndian == false)
|
|
{
|
|
{
|
|
- value |= (0xff & _buf[3]);
|
|
|
|
- value |= (0xff & _buf[2]) << 8;
|
|
|
|
- value |= (0xff & _buf[1]) << 16;
|
|
|
|
- value |= (0xff & _buf[0]) << 24;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
|
|
+ value |= (0xff & _buf[3]);
|
|
|
|
+ value |= (0xff & _buf[2]) << 8;
|
|
|
|
+ value |= (0xff & _buf[1]) << 16;
|
|
|
|
+ value |= (0xff & _buf[0]) << 24;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
{
|
|
{
|
|
- value |= (0xff & _buf[0]);
|
|
|
|
- value |= (0xff & _buf[1]) << 8;
|
|
|
|
- value |= (0xff & _buf[2]) << 16;
|
|
|
|
- value |= (0xff & _buf[3]) << 24;
|
|
|
|
- }
|
|
|
|
- _count += 4;
|
|
|
|
- return value;
|
|
|
|
- }
|
|
|
|
- throw new System.IO.EndOfStreamException();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /// <summary>
|
|
|
|
|
|
+ value |= (0xff & _buf[0]);
|
|
|
|
+ value |= (0xff & _buf[1]) << 8;
|
|
|
|
+ value |= (0xff & _buf[2]) << 16;
|
|
|
|
+ value |= (0xff & _buf[3]) << 24;
|
|
|
|
+ }
|
|
|
|
+ _count += 4;
|
|
|
|
+ return value;
|
|
|
|
+ }
|
|
|
|
+ throw new System.IO.EndOfStreamException();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
/// Reads the next two bytes of this input stream as a unsigned 16-bit integer.
|
|
/// Reads the next two bytes of this input stream as a unsigned 16-bit integer.
|
|
- /// </summary>
|
|
|
|
- /// <returns></returns>
|
|
|
|
- public int ReadUint16()
|
|
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ public int ReadUint16()
|
|
{
|
|
{
|
|
- if (_inputStream.Read(_buf, 0, 2) == 2)
|
|
|
|
|
|
+ if (_inputStream.Read(_buf, 0, 2) == 2)
|
|
{
|
|
{
|
|
- int value = 0;
|
|
|
|
- if (_isLittleEndian==false)
|
|
|
|
|
|
+ int value = 0;
|
|
|
|
+ if (_isLittleEndian == false)
|
|
|
|
+ {
|
|
|
|
+ value |= (0xff & _buf[1]);
|
|
|
|
+ value |= (0xff & _buf[0]) << 8;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
{
|
|
{
|
|
- value |= (0xff & _buf[1]);
|
|
|
|
- value |= (0xff & _buf[0]) << 8;
|
|
|
|
- } else {
|
|
|
|
- value |= (0xff & _buf[0]);
|
|
|
|
- value |= (0xff & _buf[1]) << 8;
|
|
|
|
- }
|
|
|
|
- _count += 2;
|
|
|
|
- return value;
|
|
|
|
- }
|
|
|
|
- throw new System.IO.EndOfStreamException();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ value |= (0xff & _buf[0]);
|
|
|
|
+ value |= (0xff & _buf[1]) << 8;
|
|
|
|
+ }
|
|
|
|
+ _count += 2;
|
|
|
|
+ return value;
|
|
|
|
+ }
|
|
|
|
+ throw new System.IO.EndOfStreamException();
|
|
|
|
+ }
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Reads the next four bytes of this input stream as a unsigned 32-bit integer.
|
|
/// Reads the next four bytes of this input stream as a unsigned 32-bit integer.
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
- public long ReadUint32()
|
|
|
|
|
|
+ public long ReadUint32()
|
|
{
|
|
{
|
|
- if (_inputStream.Read(_buf, 0, 4) == 4)
|
|
|
|
|
|
+ if (_inputStream.Read(_buf, 0, 4) == 4)
|
|
{
|
|
{
|
|
- long value = 0;
|
|
|
|
- if (_isLittleEndian ==false)
|
|
|
|
|
|
+ Int32 value = 0;
|
|
|
|
+ if (_isLittleEndian == false)
|
|
{
|
|
{
|
|
- value |= (0xff & _buf[3]);
|
|
|
|
- value |= (0xff & _buf[2]) << 8;
|
|
|
|
- value |= (0xff & _buf[1]) << 16;
|
|
|
|
- value |= (0xff & _buf[0]) << 24;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
|
|
+ value |= (0xff & _buf[3]);
|
|
|
|
+ value |= (0xff & _buf[2]) << 8;
|
|
|
|
+ value |= (0xff & _buf[1]) << 16;
|
|
|
|
+ value |= (0xff & _buf[0]) << 24;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
{
|
|
{
|
|
- value |= (0xff & _buf[0]);
|
|
|
|
- value |= (0xff & _buf[1]) << 8;
|
|
|
|
- value |= (0xff & _buf[2]) << 16;
|
|
|
|
- value |= (0xff & _buf[3]) << 24;
|
|
|
|
- }
|
|
|
|
- _count += 4;
|
|
|
|
- return value;
|
|
|
|
- }
|
|
|
|
- throw new System.IO.EndOfStreamException();
|
|
|
|
- }
|
|
|
|
|
|
+ value |= (0xff & _buf[0]);
|
|
|
|
+ value |= (0xff & _buf[1]) << 8;
|
|
|
|
+ value |= (0xff & _buf[2]) << 16;
|
|
|
|
+ value |= (0xff & _buf[3]) << 24;
|
|
|
|
+ }
|
|
|
|
+ _count += 4;
|
|
|
|
+ return value;
|
|
|
|
+ }
|
|
|
|
+ throw new System.IO.EndOfStreamException();
|
|
|
|
+ }
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Reads the next n bytes.
|
|
/// Reads the next n bytes.
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="n"></param>
|
|
/// <param name="n"></param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
- public byte[] ReadBytes(int n)
|
|
|
|
|
|
+ public byte[] ReadBytes(int n)
|
|
{
|
|
{
|
|
- byte[] array = new byte[n];
|
|
|
|
- if (_inputStream.Read(array,0,array.Length) == n)
|
|
|
|
|
|
+ byte[] array = new byte[n];
|
|
|
|
+ if (_inputStream.Read(array, 0, array.Length) == n)
|
|
{
|
|
{
|
|
- _count += n;
|
|
|
|
- return array;
|
|
|
|
- }
|
|
|
|
- throw new System.IO.EndOfStreamException();
|
|
|
|
- }
|
|
|
|
|
|
+ _count += n;
|
|
|
|
+ return array;
|
|
|
|
+ }
|
|
|
|
+ throw new System.IO.EndOfStreamException();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
-
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Close the input stream.
|
|
/// Close the input stream.
|
|
/// </summary>
|
|
/// </summary>
|
|
- public void Close()
|
|
|
|
|
|
+ public void Close()
|
|
{
|
|
{
|
|
- try
|
|
|
|
|
|
+ try
|
|
{
|
|
{
|
|
- _inputStream.Close();
|
|
|
|
- }
|
|
|
|
- catch(System.IO.IOException ex)
|
|
|
|
|
|
+ _inputStream.Close();
|
|
|
|
+ }
|
|
|
|
+ catch (System.IO.IOException ex)
|
|
{
|
|
{
|
|
Console.Write(ex.Message);
|
|
Console.Write(ex.Message);
|
|
- }
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
#endregion
|
|
#endregion
|