tidy
This commit is contained in:
@@ -1,44 +1,43 @@
|
||||
using System;
|
||||
using Gma.QrCodeNet.Encoding.EncodingRegion;
|
||||
|
||||
namespace Gma.QrCodeNet.Encoding.Masking;
|
||||
|
||||
public static class MatrixExtensions
|
||||
{
|
||||
public static TriStateMatrix Xor(this TriStateMatrix first, Pattern second, ErrorCorrectionLevel errorLevel)
|
||||
{
|
||||
TriStateMatrix result = XorMatrix(first, second);
|
||||
result.EmbedFormatInformation(errorLevel, second);
|
||||
return result;
|
||||
}
|
||||
public static TriStateMatrix Xor(this TriStateMatrix first, Pattern second, ErrorCorrectionLevel errorLevel)
|
||||
{
|
||||
TriStateMatrix result = XorMatrix(first, second);
|
||||
result.EmbedFormatInformation(errorLevel, second);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static TriStateMatrix XorMatrix(TriStateMatrix first, BitMatrix second)
|
||||
{
|
||||
int width = first.Width;
|
||||
TriStateMatrix maskedMatrix = new(width);
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
for (int y = 0; y < width; y++)
|
||||
{
|
||||
MatrixStatus states = first.MStatus(x, y);
|
||||
switch (states)
|
||||
{
|
||||
case MatrixStatus.NoMask:
|
||||
maskedMatrix[x, y, MatrixStatus.NoMask] = first[x, y];
|
||||
break;
|
||||
private static TriStateMatrix XorMatrix(TriStateMatrix first, BitMatrix second)
|
||||
{
|
||||
int width = first.Width;
|
||||
TriStateMatrix maskedMatrix = new(width);
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
for (int y = 0; y < width; y++)
|
||||
{
|
||||
MatrixStatus states = first.MStatus(x, y);
|
||||
switch (states)
|
||||
{
|
||||
case MatrixStatus.NoMask:
|
||||
maskedMatrix[x, y, MatrixStatus.NoMask] = first[x, y];
|
||||
break;
|
||||
|
||||
case MatrixStatus.Data:
|
||||
maskedMatrix[x, y, MatrixStatus.Data] = first[x, y] ^ second[x, y];
|
||||
break;
|
||||
case MatrixStatus.Data:
|
||||
maskedMatrix[x, y, MatrixStatus.Data] = first[x, y] ^ second[x, y];
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new ArgumentException($"{nameof(TriStateMatrix)} has None value cell.", nameof(first));
|
||||
}
|
||||
}
|
||||
}
|
||||
default:
|
||||
throw new ArgumentException($"{nameof(TriStateMatrix)} has None value cell.", nameof(first));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return maskedMatrix;
|
||||
}
|
||||
return maskedMatrix;
|
||||
}
|
||||
|
||||
public static TriStateMatrix Apply(this TriStateMatrix matrix, Pattern pattern, ErrorCorrectionLevel errorLevel) => matrix.Xor(pattern, errorLevel);
|
||||
}
|
||||
public static TriStateMatrix Apply(this TriStateMatrix matrix, Pattern pattern, ErrorCorrectionLevel errorLevel) => matrix.Xor(pattern, errorLevel);
|
||||
}
|
||||
Reference in New Issue
Block a user