diff --git a/src/ImageSharp/Common/Helpers/Numerics.cs b/src/ImageSharp/Common/Helpers/Numerics.cs
index 885443e86f..ba5c588ca5 100644
--- a/src/ImageSharp/Common/Helpers/Numerics.cs
+++ b/src/ImageSharp/Common/Helpers/Numerics.cs
@@ -226,38 +226,6 @@ namespace SixLabors.ImageSharp
return value;
}
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static ulong Clamp(ulong value, ulong min, ulong max)
- {
- if (value > max)
- {
- return max;
- }
-
- if (value < min)
- {
- return min;
- }
-
- return value;
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static long Clamp(long value, long min, long max)
- {
- if (value > max)
- {
- return max;
- }
-
- if (value < min)
- {
- return min;
- }
-
- return value;
- }
-
///
/// Returns the value clamped to the inclusive range of min and max.
///
diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifNumber.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifNumber.cs
index d16de4d224..9e206b23d1 100644
--- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifNumber.cs
+++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifNumber.cs
@@ -21,11 +21,6 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif
{
get
{
- if (this.Value > uint.MaxValue)
- {
- return ExifDataType.Long8;
- }
-
if (this.Value > ushort.MaxValue)
{
return ExifDataType.Long;
@@ -46,18 +41,6 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif
switch (value)
{
- case long longValue:
- if (longValue >= 0)
- {
- this.Value = (ulong)longValue;
- return true;
- }
-
- return false;
- case ulong ulongValue:
- this.Value = ulongValue;
-
- return true;
case int intValue:
if (intValue >= uint.MinValue)
{
diff --git a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifNumberArray.cs b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifNumberArray.cs
index 15b29dcec1..2d3a93aed3 100644
--- a/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifNumberArray.cs
+++ b/src/ImageSharp/Metadata/Profiles/Exif/Values/ExifNumberArray.cs
@@ -26,11 +26,6 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif
for (int i = 0; i < this.Value.Length; i++)
{
- if (this.Value[i] > uint.MaxValue)
- {
- return ExifDataType.Long8;
- }
-
if (this.Value[i] > ushort.MaxValue)
{
return ExifDataType.Long;
@@ -50,10 +45,6 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif
switch (value)
{
- case long val:
- return this.SetSingle(val);
- case ulong val:
- return this.SetSingle(val);
case int val:
return this.SetSingle(val);
case uint val:
@@ -62,10 +53,6 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif
return this.SetSingle(val);
case ushort val:
return this.SetSingle(val);
- case long[] array:
- return this.SetArray(array);
- case ulong[] array:
- return this.SetArray(array);
case int[] array:
return this.SetArray(array);
case uint[] array:
@@ -87,30 +74,6 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif
return true;
}
- private bool SetArray(long[] values)
- {
- var numbers = new Number[values.Length];
- for (int i = 0; i < values.Length; i++)
- {
- numbers[i] = values[i];
- }
-
- this.Value = numbers;
- return true;
- }
-
- private bool SetArray(ulong[] values)
- {
- var numbers = new Number[values.Length];
- for (int i = 0; i < values.Length; i++)
- {
- numbers[i] = values[i];
- }
-
- this.Value = numbers;
- return true;
- }
-
private bool SetArray(int[] values)
{
var numbers = new Number[values.Length];
diff --git a/src/ImageSharp/Primitives/Number.cs b/src/ImageSharp/Primitives/Number.cs
index 690b72d793..e33d2344a9 100644
--- a/src/ImageSharp/Primitives/Number.cs
+++ b/src/ImageSharp/Primitives/Number.cs
@@ -14,19 +14,19 @@ namespace SixLabors.ImageSharp
public struct Number : IEquatable, IComparable
{
[FieldOffset(0)]
- private readonly long signedValue;
+ private readonly int signedValue;
[FieldOffset(0)]
- private readonly ulong unsignedValue;
+ private readonly uint unsignedValue;
- [FieldOffset(8)]
+ [FieldOffset(4)]
private readonly bool isSigned;
///
/// Initializes a new instance of the struct.
///
/// The value of the number.
- public Number(long value)
+ public Number(int value)
: this()
{
this.signedValue = value;
@@ -37,70 +37,30 @@ namespace SixLabors.ImageSharp
/// Initializes a new instance of the struct.
///
/// The value of the number.
- public Number(ulong value)
+ public Number(uint value)
: this()
{
this.unsignedValue = value;
this.isSigned = false;
}
- ///
- /// Converts the specified to an instance of this type.
- ///
- /// The value.
- public static implicit operator Number(long value) => new Number(value);
-
- ///
- /// Converts the specified to an instance of this type.
- ///
- /// The value.
- public static implicit operator Number(ulong value) => new Number(value);
-
///
/// Converts the specified to an instance of this type.
///
/// The value.
- public static implicit operator Number(int value) => new Number((long)value);
+ public static implicit operator Number(int value) => new Number(value);
///
/// Converts the specified to an instance of this type.
///
/// The value.
- public static implicit operator Number(uint value) => new Number((ulong)value);
-
- ///
- /// Converts the specified to an instance of this type.
- ///
- /// The value.
- public static implicit operator Number(short value) => new Number((long)value);
+ public static implicit operator Number(uint value) => new Number(value);
///
/// Converts the specified to an instance of this type.
///
/// The value.
- public static implicit operator Number(ushort value) => new Number((ulong)value);
-
- ///
- /// Converts the specified to an instance of this type.
- ///
- /// The to convert.
- public static explicit operator long(Number number)
- {
- return number.isSigned
- ? number.signedValue
- : (long)Numerics.Clamp(number.unsignedValue, 0, long.MaxValue);
- }
-
- ///
- /// Converts the specified to an instance of this type.
- ///
- /// The to convert.
- public static explicit operator ulong(Number number)
- {
- return number.isSigned
- ? (ulong)Numerics.Clamp(number.signedValue, 0, long.MaxValue)
- : number.unsignedValue;
- }
+ public static implicit operator Number(ushort value) => new Number((uint)value);
///
/// Converts the specified to a .
@@ -109,8 +69,8 @@ namespace SixLabors.ImageSharp
public static explicit operator int(Number number)
{
return number.isSigned
- ? (int)Numerics.Clamp(number.signedValue, int.MinValue, int.MaxValue)
- : (int)Numerics.Clamp(number.unsignedValue, 0, (uint)int.MaxValue);
+ ? number.signedValue
+ : (int)Numerics.Clamp(number.unsignedValue, 0, int.MaxValue);
}
///
@@ -120,19 +80,8 @@ namespace SixLabors.ImageSharp
public static explicit operator uint(Number number)
{
return number.isSigned
- ? (uint)Numerics.Clamp(number.signedValue, uint.MinValue, uint.MaxValue)
- : (uint)Numerics.Clamp(number.unsignedValue, uint.MinValue, uint.MaxValue);
- }
-
- ///
- /// Converts the specified to a .
- ///
- /// The to convert.
- public static explicit operator short(Number number)
- {
- return number.isSigned
- ? (short)Numerics.Clamp(number.signedValue, short.MinValue, short.MaxValue)
- : (short)Numerics.Clamp(number.unsignedValue, 0, (ushort)short.MaxValue);
+ ? (uint)Numerics.Clamp(number.signedValue, 0, int.MaxValue)
+ : number.unsignedValue;
}
///