mirror of
https://git.code.sf.net/p/zint/code
synced 2025-12-20 03:17:12 +00:00
ERROR_* renamed to ZERROR*
This commit is contained in:
@@ -163,20 +163,32 @@ static void ecc200placement(int *array, int NR, int NC)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// calculate and append ecc code, and if necessary interleave
|
// calculate and append ecc code, and if necessary interleave
|
||||||
static void ecc200(unsigned char *binary, int bytes, int datablock, int rsblock)
|
static void ecc200(unsigned char *binary, int bytes, int datablock, int rsblock, int skew)
|
||||||
{
|
{
|
||||||
int blocks = (bytes + 2) / datablock, b;
|
int blocks = (bytes + 2) / datablock, b;
|
||||||
|
int n, p;
|
||||||
rs_init_gf(0x12d);
|
rs_init_gf(0x12d);
|
||||||
rs_init_code(rsblock, 1);
|
rs_init_code(rsblock, 1);
|
||||||
for (b = 0; b < blocks; b++) {
|
for (b = 0; b < blocks; b++) {
|
||||||
unsigned char buf[256], ecc[256];
|
unsigned char buf[256], ecc[256];
|
||||||
int n, p = 0;
|
p = 0;
|
||||||
for (n = b; n < bytes; n += blocks)
|
for (n = b; n < bytes; n += blocks)
|
||||||
buf[p++] = binary[n];
|
buf[p++] = binary[n];
|
||||||
rs_encode(p, buf, ecc);
|
rs_encode(p, buf, ecc);
|
||||||
p = rsblock - 1; // comes back reversed
|
p = rsblock - 1; // comes back reversed
|
||||||
for (n = b; n < rsblock * blocks; n += blocks)
|
for (n = b; n < rsblock * blocks; n += blocks) {
|
||||||
binary[bytes + n] = ecc[p--];
|
if (skew) {
|
||||||
|
/* Rotate ecc data to make 144x144 size symbols acceptable */
|
||||||
|
/* See http://groups.google.com/group/postscriptbarcode/msg/5ae8fda7757477da */
|
||||||
|
if(b < 8) {
|
||||||
|
binary[bytes + n + 2] = ecc[p--];
|
||||||
|
} else {
|
||||||
|
binary[bytes + n - 8] = ecc[p--];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
binary[bytes + n] = ecc[p--];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
rs_free();
|
rs_free();
|
||||||
}
|
}
|
||||||
@@ -361,7 +373,7 @@ int dm200encode(struct zint_symbol *symbol, unsigned char source[], unsigned cha
|
|||||||
if(symbol->output_options & READER_INIT) {
|
if(symbol->output_options & READER_INIT) {
|
||||||
if(gs1) {
|
if(gs1) {
|
||||||
strcpy(symbol->errtxt, "Cannot encode in GS1 mode and Reader Initialisation at the same time");
|
strcpy(symbol->errtxt, "Cannot encode in GS1 mode and Reader Initialisation at the same time");
|
||||||
return ERROR_INVALID_OPTION;
|
return ZERROR_INVALID_OPTION;
|
||||||
} else {
|
} else {
|
||||||
target[tp] = 234; tp++; /* Reader Programming */
|
target[tp] = 234; tp++; /* Reader Programming */
|
||||||
concat(binary, " ");
|
concat(binary, " ");
|
||||||
@@ -763,8 +775,8 @@ void add_tail(unsigned char target[], int tp, int tail_length, int last_mode)
|
|||||||
|
|
||||||
int data_matrix_200(struct zint_symbol *symbol, unsigned char source[], int length)
|
int data_matrix_200(struct zint_symbol *symbol, unsigned char source[], int length)
|
||||||
{
|
{
|
||||||
int inputlen, i;
|
int inputlen, i, skew = 0;
|
||||||
unsigned char binary[2000];
|
unsigned char binary[2200];
|
||||||
int binlen;
|
int binlen;
|
||||||
int symbolsize, optionsize, calcsize;
|
int symbolsize, optionsize, calcsize;
|
||||||
int taillength, error_number = 0;
|
int taillength, error_number = 0;
|
||||||
@@ -777,7 +789,7 @@ int data_matrix_200(struct zint_symbol *symbol, unsigned char source[], int leng
|
|||||||
|
|
||||||
if(binlen == 0) {
|
if(binlen == 0) {
|
||||||
strcpy(symbol->errtxt, "Data too long to fit in symbol");
|
strcpy(symbol->errtxt, "Data too long to fit in symbol");
|
||||||
return ERROR_TOO_LONG;
|
return ZERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((symbol->option_2 >= 1) && (symbol->option_2 <= 30)) {
|
if((symbol->option_2 >= 1) && (symbol->option_2 <= 30)) {
|
||||||
@@ -788,7 +800,7 @@ int data_matrix_200(struct zint_symbol *symbol, unsigned char source[], int leng
|
|||||||
|
|
||||||
calcsize = 29;
|
calcsize = 29;
|
||||||
for(i = 29; i > -1; i--) {
|
for(i = 29; i > -1; i--) {
|
||||||
if(matrixbytes[i] > binlen) {
|
if(matrixbytes[i] >= binlen) {
|
||||||
calcsize = i;
|
calcsize = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -811,7 +823,7 @@ int data_matrix_200(struct zint_symbol *symbol, unsigned char source[], int leng
|
|||||||
symbolsize = calcsize;
|
symbolsize = calcsize;
|
||||||
if(optionsize != -1) {
|
if(optionsize != -1) {
|
||||||
/* flag an error */
|
/* flag an error */
|
||||||
error_number = WARN_INVALID_OPTION;
|
error_number = ZWARN_INVALID_OPTION;
|
||||||
strcpy(symbol->errtxt, "Data does not fit in selected symbol size");
|
strcpy(symbol->errtxt, "Data does not fit in selected symbol size");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -831,7 +843,8 @@ int data_matrix_200(struct zint_symbol *symbol, unsigned char source[], int leng
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ecc code
|
// ecc code
|
||||||
ecc200(binary, bytes, datablock, rsblock);
|
if(symbolsize == 29) { skew = 1; }
|
||||||
|
ecc200(binary, bytes, datablock, rsblock, skew);
|
||||||
{ // placement
|
{ // placement
|
||||||
int x, y, NC, NR, *places;
|
int x, y, NC, NR, *places;
|
||||||
NC = W - 2 * (W / FW);
|
NC = W - 2 * (W / FW);
|
||||||
@@ -890,7 +903,7 @@ int dmatrix(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||||||
} else {
|
} else {
|
||||||
/* ECC 000 - 140 */
|
/* ECC 000 - 140 */
|
||||||
strcpy(symbol->errtxt, "Older Data Matrix standards are no longer supported");
|
strcpy(symbol->errtxt, "Older Data Matrix standards are no longer supported");
|
||||||
error_number = ERROR_INVALID_OPTION;
|
error_number = ZERROR_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
return error_number;
|
return error_number;
|
||||||
|
|||||||
Reference in New Issue
Block a user