diff --git a/backend/dmatrix.c b/backend/dmatrix.c index f66cd9bd..45aa157e 100755 --- a/backend/dmatrix.c +++ b/backend/dmatrix.c @@ -927,14 +927,14 @@ int data_matrix_200(struct zint_symbol *symbol, unsigned char source[], int leng return ERROR_TOO_LONG; } - if((symbol->option_2 >= 1) && (symbol->option_2 <= 30)) { + if((symbol->option_2 >= 1) && (symbol->option_2 <= DMSIZESCOUNT)) { optionsize = intsymbol[symbol->option_2 - 1]; } else { optionsize = -1; } - calcsize = 29; - for(i = 29; i > -1; i--) { + calcsize = DMSIZESCOUNT-1; + for(i = DMSIZESCOUNT-1; i > -1; i--) { if(matrixbytes[i] >= (binlen + process_p)) // Allow for the remaining data characters. { calcsize = i; @@ -944,12 +944,34 @@ int data_matrix_200(struct zint_symbol *symbol, unsigned char source[], int leng if(symbol->option_3 == DM_SQUARE) { /* Force to use square symbol */ switch(calcsize) { + /* Without DMRE case 2: case 4: case 6: case 9: case 11: case 14: + */ + case 2: + case 4: + case 6: + case 8: + case 9: + case 10: + case 11: + case 13: + case 14: + case 16: + case 18: + case 19: + case 20: + case 21: + case 23: + case 24: + case 25: + case 27: + case 28: + case 30: calcsize++; } } @@ -983,7 +1005,7 @@ int data_matrix_200(struct zint_symbol *symbol, unsigned char source[], int leng } // ecc code - if(symbolsize == 29) { skew = 1; } + if(symbolsize == INTSYMBOL144) { skew = 1; } ecc200(binary, bytes, datablock, rsblock, skew); { // placement int x, y, NC, NR, *places; diff --git a/backend/dmatrix.h b/backend/dmatrix.h index ee116461..48e256e6 100644 --- a/backend/dmatrix.h +++ b/backend/dmatrix.h @@ -90,19 +90,24 @@ static const int text_value[] = { // The position in the option array is by increasing total data codewords with square first static const int intsymbol[] = { - 0, /* 1: 10x10 */ 1, /* 2: 12x12 */ 3, /* 3: 14x14 */ 5, // 4: 16x16 - 7, /* 5: 18x18 */ 9, /* 6: 24x24 */ 12, /* 7: 22x22 */ 15, // 8: 24x24 - 17, /* 9: 26x26 */ 22, /* 10: 32x32 */ 26, /* 11: 36x36 */ 29, // 12: 40x40 - 31, /* 13: 44x44 */ 32, /* 14: 48x48 */ 33, /* 15: 52x52 */ 34, // 16: 64x64 - 37, /* 17: 72x72 */ 38, /* 18: 80x80 */ 39, /* 19: 88x88 */ 41, // 20: 96x96 - 42, /* 21:104x104*/ 43, /* 22:120x120*/ 44, /* 23:132x132*/ 45, // 24:144x144 - 2, /* 25: 8x18 */ 4, /* 26: 8x32 */ 6, /* 27: 12x26 */ 10, // 28: 12x36 - 13, /* 29: 16x36 */ 18, /* 30: 16x48 */ 8, /* 31: 8x48 */ 11, /* 32: 8x64 */ - 14, /* 33: 12x48 */ 16, /* 34: 12x64 */ 23, /* 35: 16x64 */ 19, /* 36: 24x32 */ - 21, /* 37: 24x36 */ 25, /* 38: 24x48 */ 28, /* 39: 24x64 */ 20, /* 40: 26x32 */ - 24, /* 41: 26x40 */ 27, /* 42: 26x48 */ 30, /* 43: 26x64 */ + 0, /* 1: 10x10 , 3*/ 1, /* 2: 12x12 , 5*/ 3, /* 3: 14x14 , 8*/ 5, // 4: 16x16 , 12 + 7, /* 5: 18x18 , 18*/ 9, /* 6: 20x20 , 22*/ 12, /* 7: 22x22 , 30*/ 15, // 8: 24x24 , 36 + 17, /* 9: 26x26 , 44*/ 22, /* 10: 32x32 , 62*/ 26, /* 11: 36x36 , 86*/ 29, // 12: 40x40 ,114 + 31, /* 13: 44x44 ,144*/ 32, /* 14: 48x48 ,174*/ 33, /* 15: 52x52 ,204*/ 34, // 16: 64x64 ,280 + 35, /* 17: 72x72 ,368*/ 36, /* 18: 80x80 ,456*/ 37, /* 19: 88x88 ,576*/ 38, // 20: 96x96 ,696 + 39, /* 21:104x104,816*/ 40, /* 22:120x120,1050*/41, /* 23:132x132,1304*/42, // 24:144x144,1558 + 2, /* 25: 8x18 , 5*/ 4, /* 26: 8x32 , 10*/ 6, /* 27: 12x26 , 16*/ 10, // 28: 12x36 , 22 + 13, /* 29: 16x36 , 32*/ 18, /* 30: 16x48 , 49*/ 8, /* 31: 8x48 , 18*/ 11, // 32: 8x64 , 24 + 14, /* 33: 12x48 , 32*/ 16, /* 34: 12x64 , 43*/ 23, /* 35: 16x64 , 62*/ 19, // 36: 24x32 , 49 + 21, /* 37: 24x36 , 55*/ 25, /* 38: 24x48 , 80*/ 28, /* 39: 24x64 ,108*/ 20, // 40: 26x32 , 52 + 24, /* 41: 26x40 , 70*/ 27, /* 42: 26x48 , 90*/ 30, /* 43: 26x64 ,118*/ 0 }; +// Number of DM Sizes +#define DMSIZESCOUNT 44 +// Number of 144x144 for special interlace +#define INTSYMBOL144 42 + // Horizontal matrix size static const int matrixH[] = { @@ -114,7 +119,7 @@ static const int matrixH[] = { /*20*/ 26, /* 26x32 ,52 */ 24, /* 24x36 ,55 */ 32, /* 32x32 ,62 */ 16, /* 16x64 ,62 */ /*24*/ 26, /* 26x40 ,70 */ 24, /* 24x48 ,80 */ 36, /* 36x36 ,86 */ 26, /* 26x48 ,90 */ /*28*/ 24, /* 24x64 ,108*/ 40, /* 40x40 ,114*/ 26, /* 26x64 ,118*/ 44, /* 44x44 ,144*/ -/*32*/ 48, /* 48x48,174 */ 52, /* 62x52,204 */ 64, /* 64x64,280 */ 72, /* 72x72,368 */ +/*32*/ 48, /* 48x48,174 */ 52, /* 52x52,204 */ 64, /* 64x64,280 */ 72, /* 72x72,368 */ /*36*/ 80, /* 80x80,456 */ 88, /* 88x88,576 */ 96, /* 96x96,696 */ 104,/*104x104,816*/ /*40*/ 120,/*120x120,1050*/132,/*132x132,1304*/144/*144x144,1558*/ };