Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 51 additions & 1 deletion Source/lib/datamatrix/encoder/ErrorCorrection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static class ErrorCorrection
/// See FACTORS.
/// </summary>
private static readonly int[] FACTOR_SETS
= {5, 7, 10, 11, 12, 14, 18, 20, 24, 28, 36, 42, 48, 56, 62, 68};
= {5, 7, 10, 11, 12, 14, 15, 18, 20, 22, 24, 27, 28, 32, 34, 36, 38, 41, 42, 46, 48, 50, 56, 62, 68};

/// <summary>
/// Precomputed polynomial factors for ECC 200.
Expand All @@ -42,6 +42,7 @@ private static readonly int[] FACTOR_SETS
new[] {175, 138, 205, 12, 194, 168, 39, 245, 60, 97, 120},
new[] {41, 153, 158, 91, 61, 42, 142, 213, 97, 178, 100, 242},
new[] {156, 97, 192, 252, 95, 9, 157, 119, 138, 45, 18, 186, 83, 185},
new[] {116, 88, 33, 148, 201, 88, 153, 176, 234, 145, 35, 159, 139, 223, 93 },
new[]
{
83, 195, 100, 39, 188, 75, 66, 61, 241, 213, 109, 129, 94, 254,
Expand All @@ -55,18 +56,41 @@ private static readonly int[] FACTOR_SETS
82, 27, 174, 186, 172
},
new[]
{
75, 249, 76, 201, 95, 241, 5, 123, 71, 94, 27, 132, 1, 152, 38,
10, 125, 217, 209, 3, 188, 236
},
new[]
{
52, 190, 88, 205, 109, 39, 176, 21, 155, 197, 251, 223, 155, 21, 5, 172,
254, 124, 12, 181, 184, 96, 50, 193
},
new[]
{
215, 183, 130, 96, 182, 147, 97, 74, 143, 205, 47, 229, 29,
123, 55, 65, 244, 246, 210, 108, 72, 134, 233, 246, 161, 180,
232
},
new[]
{
211, 231, 43, 97, 71, 96, 103, 174, 37, 151, 170, 53, 75, 34,
249,
121,
17, 138, 110, 213, 141, 136, 120, 151, 233, 168, 93, 255
},
new[]
{
227, 184, 159, 130, 228, 199, 107, 95, 236, 21, 61, 58, 209,
120, 2, 38, 211, 202, 103, 19, 104, 145, 2, 249, 174, 144,
95, 55, 234, 163, 129, 104
},
new[]
{
190, 197, 231, 218, 210, 172, 71, 234, 203, 95, 42, 103, 237,
116, 90, 95, 143, 6, 189, 114, 107, 62, 154, 62, 152, 237, 138,
89, 14, 67, 189, 179, 4, 139
},
new[]
{
245, 127, 242, 218, 130, 250, 162, 181, 102, 120, 84, 179, 220,
251, 80, 182,
Expand All @@ -75,6 +99,18 @@ private static readonly int[] FACTOR_SETS
225, 98, 81, 112
},
new[]
{
109, 30, 101, 141, 239, 222, 166, 90, 102, 168, 237, 74, 233,
143, 123, 203, 41, 172, 103, 139, 211, 55, 183, 83, 215, 122,
223, 170, 134, 80, 128, 220, 169, 166, 241, 165, 181, 235
},
new[]
{
35, 21, 123, 106, 43, 2, 142, 6, 222, 194, 48, 53, 99, 216, 193,
172, 136, 101, 120, 156, 250, 137, 144, 84, 165, 90, 211, 208,
132, 133, 15, 224, 244, 79, 71, 81, 38, 68, 249, 220, 149
},
new[]
{
77, 193, 137, 31, 19, 38, 22, 153, 247, 105, 122, 2, 245, 133,
242, 8,
Expand All @@ -84,6 +120,13 @@ private static readonly int[] FACTOR_SETS
248, 202, 69, 50, 150, 177, 226, 5, 9, 5
},
new[]
{
195, 29, 197, 200, 113, 135, 114, 178, 160, 232, 186, 35, 129,
111, 51, 47, 61, 11, 29, 135, 171, 83, 221, 33, 206, 130, 127,
47, 77, 21, 43, 72, 138, 173, 118, 144, 98, 40, 178, 141, 62,
114, 235, 74, 62, 78
},
new[]
{
245, 132, 172, 223, 96, 32, 117, 22, 238, 133, 238, 231, 205,
188,
Expand All @@ -94,6 +137,13 @@ private static readonly int[] FACTOR_SETS
225, 19
},
new[]
{
1, 166, 254, 165, 43, 167, 102, 150, 123, 245, 74, 222, 223, 36,
230, 112, 16, 9, 142, 14, 241, 251, 114, 65, 156, 205, 14, 80,
76, 243, 241, 8, 185, 25, 28, 112, 231, 79, 153, 16, 74, 156,
183, 212, 218, 167, 91, 162, 54, 74
},
new[]
{
175, 9, 223, 238, 12, 17, 220, 208, 100, 29, 175, 170, 230, 192,
215, 235,
Expand Down
39 changes: 38 additions & 1 deletion Source/lib/datamatrix/encoder/SymbolInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,35 @@ public class SymbolInfo
/*rect*/new SymbolInfo(true, 16, 14, 24, 10, 1),

new SymbolInfo(false, 18, 14, 16, 16, 1),
/*rect*/new SymbolInfo(true, 18, 15, 22, 6, 2, true), // DMRE 8x48 (18)
new SymbolInfo(false, 22, 18, 18, 18, 1),
/*rect*/new SymbolInfo(true, 22, 18, 16, 10, 2),
/*rect*/new SymbolInfo(true, 24, 18, 14, 6, 4, true), // DMRE 8x64 (24)
new SymbolInfo(false, 30, 20, 20, 20, 1),
/*rect*/new SymbolInfo(true, 32, 24, 16, 14, 2),
/*rect*/new SymbolInfo(true, 32, 22, 18, 6, 4, true), // DMRE 8x80 (32)
new SymbolInfo(false, 36, 24, 22, 22, 1),
/*rect*/new SymbolInfo(true, 38, 28, 22, 6, 4, true), // DMRE 8x96 (38)
/*rect*/new SymbolInfo(true, 43, 27, 14, 10, 4, true), // DMRE 12x64 (43)
new SymbolInfo(false, 44, 28, 24, 24, 1),
/*rect*/new SymbolInfo(true, 44, 28, 16, 18, 2, true), // DMRE 20x36 (44)
/*rect*/new SymbolInfo(true, 49, 28, 22, 14, 2),
/*rect*/new SymbolInfo(true, 49, 32, 18, 6, 6, true), // DMRE 8x120 (49)
/*rect*/new SymbolInfo(true, 56, 34, 20, 18, 2, true), // DMRE 20x44 (56)

new SymbolInfo(false, 62, 36, 14, 14, 4),
/*rect*/new SymbolInfo(true, 62, 36, 14, 14, 4, true), // DMRE 16x64 (62)
/*rect*/new SymbolInfo(true, 63, 36, 22, 6, 6, true), // DMRE 8x144 (63)
/*rect*/new SymbolInfo(true, 64, 36, 20, 10, 4, true), // DMRE 12x88 (64)
/*rect*/new SymbolInfo(true, 70, 38, 18, 24, 2, true), // DMRE 26x40 (70)
/*rect*/new SymbolInfo(true, 72, 38, 22, 20, 2, true), // DMRE 22x48 (72)
/*rect*/new SymbolInfo(true, 80, 41, 22, 22, 2, true), // DMRE 24x48 (80)
/*rect*/new SymbolInfo(true, 84, 42, 14, 18, 4, true), // DMRE 20x64 (84)
new SymbolInfo(false, 86, 42, 16, 16, 4),
/*rect*/new SymbolInfo(true, 90, 42, 22, 24, 2, true), // DMRE 26x48 (90)
/*rect*/new SymbolInfo(true, 108, 46, 14, 22, 4, true), // DMRE 24x64 (108)
new SymbolInfo(false, 114, 48, 18, 18, 4),
/*rect*/new SymbolInfo(true, 118, 50, 14, 24, 4, true), // DMRE 26x64 (118)
new SymbolInfo(false, 144, 56, 20, 20, 4),
new SymbolInfo(false, 174, 68, 22, 22, 4),

Expand Down Expand Up @@ -76,6 +94,7 @@ public class SymbolInfo
private readonly int dataRegions;
private readonly int rsBlockData;
private readonly int rsBlockError;
private readonly bool dmre;

/**
* Overrides the symbol info set used by this class. Used for testing purposes.
Expand All @@ -101,10 +120,16 @@ public SymbolInfo(bool rectangular, int dataCapacity, int errorCodewords,
dataCapacity, errorCodewords)
{
}
public SymbolInfo(bool rectangular, int dataCapacity, int errorCodewords,
int matrixWidth, int matrixHeight, int dataRegions, bool dmre = false)
: this(rectangular, dataCapacity, errorCodewords, matrixWidth, matrixHeight, dataRegions,
dataCapacity, errorCodewords, dmre)
{
}

internal SymbolInfo(bool rectangular, int dataCapacity, int errorCodewords,
int matrixWidth, int matrixHeight, int dataRegions,
int rsBlockData, int rsBlockError)
int rsBlockData, int rsBlockError, bool dmre = false)
{
this.rectangular = rectangular;
this.dataCapacity = dataCapacity;
Expand All @@ -114,7 +139,9 @@ internal SymbolInfo(bool rectangular, int dataCapacity, int errorCodewords,
this.dataRegions = dataRegions;
this.rsBlockData = rsBlockData;
this.rsBlockError = rsBlockError;
this.dmre = dmre;
}

/// <summary>
///
/// </summary>
Expand Down Expand Up @@ -205,6 +232,11 @@ public static SymbolInfo lookup(int dataCodewords,

private int getHorizontalDataRegions()
{
if (dmre)
{
return dataRegions;
}

switch (dataRegions)
{
case 1:
Expand All @@ -223,6 +255,11 @@ private int getHorizontalDataRegions()

private int getVerticalDataRegions()
{
if (dmre)
{
return 1;
}

switch (dataRegions)
{
case 1:
Expand Down