diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Matrix.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Matrix.cs
index 61ecda4aa..ecc9bfbff 100644
--- a/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Matrix.cs
+++ b/src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.Matrix.cs
@@ -17,16 +17,23 @@ internal sealed partial class IccDataReader
/// The read matrix
public float[,] ReadMatrix(int xCount, int yCount, bool isSingle)
{
- var matrix = new float[xCount, yCount];
- for (int y = 0; y < yCount; y++)
+ float[,] matrix = new float[xCount, yCount];
+
+ if (isSingle)
{
- for (int x = 0; x < xCount; x++)
+ for (int y = 0; y < yCount; y++)
{
- if (isSingle)
+ for (int x = 0; x < xCount; x++)
{
matrix[x, y] = this.ReadSingle();
}
- else
+ }
+ }
+ else
+ {
+ for (int y = 0; y < yCount; y++)
+ {
+ for (int x = 0; x < xCount; x++)
{
matrix[x, y] = this.ReadFix16();
}
@@ -44,14 +51,17 @@ internal sealed partial class IccDataReader
/// The read matrix
public float[] ReadMatrix(int yCount, bool isSingle)
{
- var matrix = new float[yCount];
- for (int i = 0; i < yCount; i++)
+ float[] matrix = new float[yCount];
+ if (isSingle)
{
- if (isSingle)
+ for (int i = 0; i < yCount; i++)
{
matrix[i] = this.ReadSingle();
}
- else
+ }
+ else
+ {
+ for (int i = 0; i < yCount; i++)
{
matrix[i] = this.ReadFix16();
}
diff --git a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.Matrix.cs b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.Matrix.cs
index 1e5f359e0..636cc90a5 100644
--- a/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.Matrix.cs
+++ b/src/ImageSharp/Metadata/Profiles/ICC/DataWriter/IccDataWriter.Matrix.cs
@@ -1,4 +1,4 @@
-// Copyright (c) Six Labors.
+// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
using System.Numerics;
@@ -61,15 +61,21 @@ internal sealed partial class IccDataWriter
public int WriteMatrix(in DenseMatrix value, bool isSingle)
{
int count = 0;
- for (int y = 0; y < value.Rows; y++)
+ if (isSingle)
{
- for (int x = 0; x < value.Columns; x++)
+ for (int y = 0; y < value.Rows; y++)
{
- if (isSingle)
+ for (int x = 0; x < value.Columns; x++)
{
count += this.WriteSingle(value[x, y]);
}
- else
+ }
+ }
+ else
+ {
+ for (int y = 0; y < value.Rows; y++)
+ {
+ for (int x = 0; x < value.Columns; x++)
{
count += this.WriteFix16(value[x, y]);
}
@@ -88,15 +94,22 @@ internal sealed partial class IccDataWriter
public int WriteMatrix(float[,] value, bool isSingle)
{
int count = 0;
- for (int y = 0; y < value.GetLength(1); y++)
+
+ if (isSingle)
{
- for (int x = 0; x < value.GetLength(0); x++)
+ for (int y = 0; y < value.GetLength(1); y++)
{
- if (isSingle)
+ for (int x = 0; x < value.GetLength(0); x++)
{
count += this.WriteSingle(value[x, y]);
}
- else
+ }
+ }
+ else
+ {
+ for (int y = 0; y < value.GetLength(1); y++)
+ {
+ for (int x = 0; x < value.GetLength(0); x++)
{
count += this.WriteFix16(value[x, y]);
}