diff --git a/src/ImageSharp.Formats.Tiff/TiffConstants.cs b/src/ImageSharp.Formats.Tiff/TiffConstants.cs
index 73508b34a..84b90e69f 100644
--- a/src/ImageSharp.Formats.Tiff/TiffConstants.cs
+++ b/src/ImageSharp.Formats.Tiff/TiffConstants.cs
@@ -36,5 +36,20 @@ namespace ImageSharp.Formats
/// Size (in bytes) of each individual TIFF IFD entry
///
public const int SizeOfIfdEntry = 12;
+
+ ///
+ /// Size (in bytes) of the Short and SShort data types
+ ///
+ public const int SizeOfShort = 2;
+
+ ///
+ /// Size (in bytes) of the Long and SLong data types
+ ///
+ public const int SizeOfLong = 4;
+
+ ///
+ /// Size (in bytes) of the Rational and SRational data types
+ ///
+ public const int SizeOfRational = 8;
}
}
diff --git a/src/ImageSharp.Formats.Tiff/TiffDecoderCore.cs b/src/ImageSharp.Formats.Tiff/TiffDecoderCore.cs
index 309050f41..7d5bcf519 100644
--- a/src/ImageSharp.Formats.Tiff/TiffDecoderCore.cs
+++ b/src/ImageSharp.Formats.Tiff/TiffDecoderCore.cs
@@ -203,13 +203,13 @@ namespace ImageSharp.Formats
case TiffType.Short:
{
for (int i = 0 ; i < result.Length ; i++)
- result[i] = (uint)ToUInt16(bytes, i * 2);
+ result[i] = (uint)ToUInt16(bytes, i * TiffConstants.SizeOfShort);
break;
}
case TiffType.Long:
{
for (int i = 0 ; i < result.Length ; i++)
- result[i] = ToUInt32(bytes, i * 4);
+ result[i] = ToUInt32(bytes, i * TiffConstants.SizeOfLong);
break;
}
default:
@@ -235,13 +235,13 @@ namespace ImageSharp.Formats
case TiffType.SShort:
{
for (int i = 0 ; i < result.Length ; i++)
- result[i] = (int)ToInt16(bytes, i * 2);
+ result[i] = (int)ToInt16(bytes, i * TiffConstants.SizeOfShort);
break;
}
case TiffType.SLong:
{
for (int i = 0 ; i < result.Length ; i++)
- result[i] = ToInt32(bytes, i * 4);
+ result[i] = ToInt32(bytes, i * TiffConstants.SizeOfLong);
break;
}
default:
@@ -290,8 +290,8 @@ namespace ImageSharp.Formats
for (int i = 0 ; i < result.Length ; i++)
{
- uint numerator = ToUInt32(bytes, i * 8);
- uint denominator = ToUInt32(bytes, i * 8 + 4);
+ uint numerator = ToUInt32(bytes, i * TiffConstants.SizeOfRational);
+ uint denominator = ToUInt32(bytes, i * TiffConstants.SizeOfRational + TiffConstants.SizeOfLong);
result[i] = new Rational(numerator, denominator);
}
@@ -308,8 +308,8 @@ namespace ImageSharp.Formats
for (int i = 0 ; i < result.Length ; i++)
{
- int numerator = ToInt32(bytes, i * 8);
- int denominator = ToInt32(bytes, i * 8 + 4);
+ int numerator = ToInt32(bytes, i * TiffConstants.SizeOfRational);
+ int denominator = ToInt32(bytes, i * TiffConstants.SizeOfRational + TiffConstants.SizeOfLong);
result[i] = new SignedRational(numerator, denominator);
}