diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/Atkinson.cs b/src/ImageSharp/Dithering/ErrorDiffusion/Atkinson.cs
index 934df7e4a8..76a5f96ec9 100644
--- a/src/ImageSharp/Dithering/ErrorDiffusion/Atkinson.cs
+++ b/src/ImageSharp/Dithering/ErrorDiffusion/Atkinson.cs
@@ -14,11 +14,11 @@ namespace ImageSharp.Dithering
///
/// The diffusion matrix
///
- private static readonly byte[,] AtkinsonMatrix =
+ private static readonly byte[][] AtkinsonMatrix =
{
- { 0, 0, 1, 1 },
- { 1, 1, 1, 0 },
- { 0, 1, 0, 0 }
+ new byte[] { 0, 0, 1, 1 },
+ new byte[] { 1, 1, 1, 0 },
+ new byte[] { 0, 1, 0, 0 }
};
///
diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/Burks.cs b/src/ImageSharp/Dithering/ErrorDiffusion/Burks.cs
index 311316685b..2d71b9cc35 100644
--- a/src/ImageSharp/Dithering/ErrorDiffusion/Burks.cs
+++ b/src/ImageSharp/Dithering/ErrorDiffusion/Burks.cs
@@ -14,10 +14,10 @@ namespace ImageSharp.Dithering
///
/// The diffusion matrix
///
- private static readonly byte[,] BurksMatrix =
+ private static readonly byte[][] BurksMatrix =
{
- { 0, 0, 0, 8, 4 },
- { 2, 4, 8, 4, 2 }
+ new byte[] { 0, 0, 0, 8, 4 },
+ new byte[] { 2, 4, 8, 4, 2 }
};
///
diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/ErrorDiffuser.cs b/src/ImageSharp/Dithering/ErrorDiffusion/ErrorDiffuser.cs
index 1de6cd8149..0c2a1dc404 100644
--- a/src/ImageSharp/Dithering/ErrorDiffusion/ErrorDiffuser.cs
+++ b/src/ImageSharp/Dithering/ErrorDiffusion/ErrorDiffuser.cs
@@ -39,20 +39,20 @@ namespace ImageSharp.Dithering
///
/// The dithering matrix.
/// The divisor.
- protected ErrorDiffuser(byte[,] matrix, byte divisor)
+ protected ErrorDiffuser(byte[][] matrix, byte divisor)
{
Guard.NotNull(matrix, nameof(matrix));
Guard.MustBeGreaterThan(divisor, 0, nameof(divisor));
this.Matrix = matrix;
- this.matrixWidth = (byte)(matrix.GetUpperBound(1) + 1);
- this.matrixHeight = (byte)(matrix.GetUpperBound(0) + 1);
+ this.matrixWidth = (byte)matrix[0].Length;
+ this.matrixHeight = (byte)matrix.Length;
this.divisorVector = new Vector4(divisor);
this.startingOffset = 0;
for (int i = 0; i < this.matrixWidth; i++)
{
- if (matrix[0, i] != 0)
+ if (matrix[0][i] != 0)
{
this.startingOffset = (byte)(i - 1);
break;
@@ -61,7 +61,7 @@ namespace ImageSharp.Dithering
}
///
- public byte[,] Matrix { get; }
+ public byte[][] Matrix { get; }
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -85,13 +85,13 @@ namespace ImageSharp.Dithering
if (matrixX > 0 && matrixX < width && matrixY > 0 && matrixY < height)
{
- byte coefficient = this.Matrix[row, col];
+ byte coefficient = this.Matrix[row][col];
if (coefficient == 0)
{
continue;
}
- Vector4 coefficientVector = new Vector4(this.Matrix[row, col]);
+ Vector4 coefficientVector = new Vector4(this.Matrix[row][col]);
Vector4 offsetColor = pixels[matrixX, matrixY].ToVector4();
Vector4 result = ((error * coefficientVector) / this.divisorVector) + offsetColor;
result.W = offsetColor.W;
diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/FloydSteinberg.cs b/src/ImageSharp/Dithering/ErrorDiffusion/FloydSteinberg.cs
index a392c9dc9c..cf91bd8fab 100644
--- a/src/ImageSharp/Dithering/ErrorDiffusion/FloydSteinberg.cs
+++ b/src/ImageSharp/Dithering/ErrorDiffusion/FloydSteinberg.cs
@@ -14,10 +14,10 @@ namespace ImageSharp.Dithering
///
/// The diffusion matrix
///
- private static readonly byte[,] FloydSteinbergMatrix =
+ private static readonly byte[][] FloydSteinbergMatrix =
{
- { 0, 0, 7 },
- { 3, 5, 1 }
+ new byte[] { 0, 0, 7 },
+ new byte[] { 3, 5, 1 }
};
///
diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/IErrorDiffuser.cs b/src/ImageSharp/Dithering/ErrorDiffusion/IErrorDiffuser.cs
index 22cbad1e6e..eb6c27167e 100644
--- a/src/ImageSharp/Dithering/ErrorDiffusion/IErrorDiffuser.cs
+++ b/src/ImageSharp/Dithering/ErrorDiffusion/IErrorDiffuser.cs
@@ -15,7 +15,7 @@ namespace ImageSharp.Dithering
///
/// Gets the dithering matrix
///
- byte[,] Matrix { get; }
+ byte[][] Matrix { get; }
///
/// Transforms the image applying the dither matrix. This method alters the input pixels array
diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/JarvisJudiceNinke.cs b/src/ImageSharp/Dithering/ErrorDiffusion/JarvisJudiceNinke.cs
index b5876d7773..5f26d8b248 100644
--- a/src/ImageSharp/Dithering/ErrorDiffusion/JarvisJudiceNinke.cs
+++ b/src/ImageSharp/Dithering/ErrorDiffusion/JarvisJudiceNinke.cs
@@ -14,11 +14,11 @@ namespace ImageSharp.Dithering
///
/// The diffusion matrix
///
- private static readonly byte[,] JarvisJudiceNinkeMatrix =
+ private static readonly byte[][] JarvisJudiceNinkeMatrix =
{
- { 0, 0, 0, 7, 5 },
- { 3, 5, 7, 5, 3 },
- { 1, 3, 5, 3, 1 }
+ new byte[] { 0, 0, 0, 7, 5 },
+ new byte[] { 3, 5, 7, 5, 3 },
+ new byte[] { 1, 3, 5, 3, 1 }
};
///
diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/Sierra2.cs b/src/ImageSharp/Dithering/ErrorDiffusion/Sierra2.cs
index d7cc84254e..44132747d9 100644
--- a/src/ImageSharp/Dithering/ErrorDiffusion/Sierra2.cs
+++ b/src/ImageSharp/Dithering/ErrorDiffusion/Sierra2.cs
@@ -14,10 +14,10 @@ namespace ImageSharp.Dithering
///
/// The diffusion matrix
///
- private static readonly byte[,] Sierra2Matrix =
+ private static readonly byte[][] Sierra2Matrix =
{
- { 0, 0, 0, 4, 3 },
- { 1, 2, 3, 2, 1 }
+ new byte[] { 0, 0, 0, 4, 3 },
+ new byte[] { 1, 2, 3, 2, 1 }
};
///
diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/Sierra3.cs b/src/ImageSharp/Dithering/ErrorDiffusion/Sierra3.cs
index c3d1fe7565..01f6b5ded7 100644
--- a/src/ImageSharp/Dithering/ErrorDiffusion/Sierra3.cs
+++ b/src/ImageSharp/Dithering/ErrorDiffusion/Sierra3.cs
@@ -14,11 +14,11 @@ namespace ImageSharp.Dithering
///
/// The diffusion matrix
///
- private static readonly byte[,] Sierra3Matrix =
+ private static readonly byte[][] Sierra3Matrix =
{
- { 0, 0, 0, 5, 3 },
- { 2, 4, 5, 4, 2 },
- { 0, 2, 3, 2, 0 }
+ new byte[] { 0, 0, 0, 5, 3 },
+ new byte[] { 2, 4, 5, 4, 2 },
+ new byte[] { 0, 2, 3, 2, 0 }
};
///
diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/SierraLite.cs b/src/ImageSharp/Dithering/ErrorDiffusion/SierraLite.cs
index 7d855b84e3..42fa8c23d2 100644
--- a/src/ImageSharp/Dithering/ErrorDiffusion/SierraLite.cs
+++ b/src/ImageSharp/Dithering/ErrorDiffusion/SierraLite.cs
@@ -14,10 +14,10 @@ namespace ImageSharp.Dithering
///
/// The diffusion matrix
///
- private static readonly byte[,] SierraLiteMatrix =
+ private static readonly byte[][] SierraLiteMatrix =
{
- { 0, 0, 2 },
- { 1, 1, 0 }
+ new byte[] { 0, 0, 2 },
+ new byte[] { 1, 1, 0 }
};
///
diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/Stucki.cs b/src/ImageSharp/Dithering/ErrorDiffusion/Stucki.cs
index 3cc01aa798..0e462630e9 100644
--- a/src/ImageSharp/Dithering/ErrorDiffusion/Stucki.cs
+++ b/src/ImageSharp/Dithering/ErrorDiffusion/Stucki.cs
@@ -14,11 +14,11 @@ namespace ImageSharp.Dithering
///
/// The diffusion matrix
///
- private static readonly byte[,] StuckiMatrix =
+ private static readonly byte[][] StuckiMatrix =
{
- { 0, 0, 0, 8, 4 },
- { 2, 4, 8, 4, 2 },
- { 1, 2, 4, 2, 1 }
+ new byte[] { 0, 0, 0, 8, 4 },
+ new byte[] { 2, 4, 8, 4, 2 },
+ new byte[] { 1, 2, 4, 2, 1 }
};
///
diff --git a/src/ImageSharp/Dithering/Ordered/Bayer.cs b/src/ImageSharp/Dithering/Ordered/Bayer.cs
index 3674be0aaf..c560889790 100644
--- a/src/ImageSharp/Dithering/Ordered/Bayer.cs
+++ b/src/ImageSharp/Dithering/Ordered/Bayer.cs
@@ -17,23 +17,23 @@ namespace ImageSharp.Dithering.Ordered
/// The threshold matrix.
/// This is calculated by multiplying each value in the original matrix by 16 and subtracting 1
///
- private static readonly byte[,] ThresholdMatrix =
+ private static readonly byte[][] ThresholdMatrix =
{
- { 15, 143, 47, 175 },
- { 207, 79, 239, 111 },
- { 63, 191, 31, 159 },
- { 255, 127, 223, 95 }
+ new byte[] { 15, 143, 47, 175 },
+ new byte[] { 207, 79, 239, 111 },
+ new byte[] { 63, 191, 31, 159 },
+ new byte[] { 255, 127, 223, 95 }
};
///
- public byte[,] Matrix { get; } = ThresholdMatrix;
+ public byte[][] Matrix { get; } = ThresholdMatrix;
///
public void Dither(PixelAccessor pixels, TColor source, TColor upper, TColor lower, byte[] bytes, int index, int x, int y, int width, int height)
where TColor : struct, IPackedPixel, IEquatable
{
source.ToXyzwBytes(bytes, 0);
- pixels[x, y] = ThresholdMatrix[x % 3, y % 3] >= bytes[index] ? lower : upper;
+ pixels[x, y] = ThresholdMatrix[x % 3][y % 3] >= bytes[index] ? lower : upper;
}
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/Dithering/Ordered/IOrderedDither.cs b/src/ImageSharp/Dithering/Ordered/IOrderedDither.cs
index 910b275f94..464b9d4199 100644
--- a/src/ImageSharp/Dithering/Ordered/IOrderedDither.cs
+++ b/src/ImageSharp/Dithering/Ordered/IOrderedDither.cs
@@ -15,7 +15,7 @@ namespace ImageSharp.Dithering
///
/// Gets the dithering matrix
///
- byte[,] Matrix { get; }
+ byte[][] Matrix { get; }
///
/// Transforms the image applying the dither matrix. This method alters the input pixels array
diff --git a/src/ImageSharp/Dithering/Ordered/Ordered.cs b/src/ImageSharp/Dithering/Ordered/Ordered.cs
index 2e7766e0bd..38f8f21a57 100644
--- a/src/ImageSharp/Dithering/Ordered/Ordered.cs
+++ b/src/ImageSharp/Dithering/Ordered/Ordered.cs
@@ -17,23 +17,23 @@ namespace ImageSharp.Dithering.Ordered
/// The threshold matrix.
/// This is calculated by multiplying each value in the original matrix by 16
///
- private static readonly byte[,] ThresholdMatrix =
+ private static readonly byte[][] ThresholdMatrix =
{
- { 0, 128, 32, 160 },
- { 192, 64, 224, 96 },
- { 48, 176, 16, 144 },
- { 240, 112, 208, 80 }
+ new byte[] { 0, 128, 32, 160 },
+ new byte[] { 192, 64, 224, 96 },
+ new byte[] { 48, 176, 16, 144 },
+ new byte[] { 240, 112, 208, 80 }
};
///
- public byte[,] Matrix { get; } = ThresholdMatrix;
+ public byte[][] Matrix { get; } = ThresholdMatrix;
///
public void Dither(PixelAccessor pixels, TColor source, TColor upper, TColor lower, byte[] bytes, int index, int x, int y, int width, int height)
where TColor : struct, IPackedPixel, IEquatable
{
source.ToXyzwBytes(bytes, 0);
- pixels[x, y] = ThresholdMatrix[x % 3, y % 3] >= bytes[index] ? lower : upper;
+ pixels[x, y] = ThresholdMatrix[x % 3][y % 3] >= bytes[index] ? lower : upper;
}
}
}
\ No newline at end of file