|
|
@ -9,7 +9,7 @@ using System.Text; |
|
|
namespace SixLabors.ImageSharp.IO |
|
|
namespace SixLabors.ImageSharp.IO |
|
|
{ |
|
|
{ |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Equivalent of <see cref="BinaryReader"/>, but with either endianness, depending on the <see cref="EndianBitConverter"/> it is constructed with.
|
|
|
/// Equivalent of <see cref="BinaryReader"/>, but with either endianness.
|
|
|
/// No data is buffered in the reader; the client may seek within the stream at will.
|
|
|
/// No data is buffered in the reader; the client may seek within the stream at will.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
internal class EndianBinaryReader : IDisposable |
|
|
internal class EndianBinaryReader : IDisposable |
|
|
@ -46,8 +46,7 @@ namespace SixLabors.ImageSharp.IO |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Initializes a new instance of the <see cref="EndianBinaryReader"/> class.
|
|
|
/// Initializes a new instance of the <see cref="EndianBinaryReader"/> class.
|
|
|
/// Equivalent of <see cref="System.IO.BinaryWriter"/>, but with either endianness, depending on
|
|
|
/// Modeled after <see cref="System.IO.BinaryWriter"/> with endian support.
|
|
|
/// the EndianBitConverter it is constructed with.
|
|
|
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="endianness">
|
|
|
/// <param name="endianness">
|
|
|
/// Endianness to use when reading data
|
|
|
/// Endianness to use when reading data
|
|
|
@ -238,7 +237,7 @@ namespace SixLabors.ImageSharp.IO |
|
|
/// <returns>The floating point value read</returns>
|
|
|
/// <returns>The floating point value read</returns>
|
|
|
public unsafe float ReadSingle() |
|
|
public unsafe float ReadSingle() |
|
|
{ |
|
|
{ |
|
|
int intValue = ReadInt32(); |
|
|
int intValue = this.ReadInt32(); |
|
|
|
|
|
|
|
|
return *((float*)&intValue); |
|
|
return *((float*)&intValue); |
|
|
} |
|
|
} |
|
|
@ -255,24 +254,6 @@ namespace SixLabors.ImageSharp.IO |
|
|
return *((double*)&value); |
|
|
return *((double*)&value); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Reads a decimal value from the stream, using the bit converter
|
|
|
|
|
|
/// for this reader. 16 bytes are read.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns>The decimal value read</returns>
|
|
|
|
|
|
public unsafe decimal ReadDecimal() |
|
|
|
|
|
{ |
|
|
|
|
|
decimal result = 0m; |
|
|
|
|
|
int* presult = (int*)&result; |
|
|
|
|
|
|
|
|
|
|
|
presult[0] = this.ReadInt32(); |
|
|
|
|
|
presult[1] = this.ReadInt32(); |
|
|
|
|
|
presult[2] = this.ReadInt32(); |
|
|
|
|
|
presult[3] = this.ReadInt32(); |
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Reads a single character from the stream, using the character encoding for
|
|
|
/// Reads a single character from the stream, using the character encoding for
|
|
|
/// this reader. If no characters have been fully read by the time the stream ends,
|
|
|
/// this reader. If no characters have been fully read by the time the stream ends,
|
|
|
|