mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Add Reader Initialisation mode
This commit is contained in:
parent
1ac256c223
commit
e3e9c67f93
@ -93,7 +93,7 @@ int character_subset_select(unsigned char source[], int input_position) {
|
|||||||
return MODEB;
|
return MODEB;
|
||||||
}
|
}
|
||||||
|
|
||||||
int data_encode_blockf(unsigned char source[], int input_length, int subset_selector[], int blockmatrix[][62], int *columns_needed, int *rows_needed, int *final_mode, int gs1)
|
int data_encode_blockf(unsigned char source[], int input_length, int subset_selector[], int blockmatrix[][62], int *columns_needed, int *rows_needed, int *final_mode, int gs1, int reader)
|
||||||
{
|
{
|
||||||
int i, j, input_position, current_mode, current_row, error_number;
|
int i, j, input_position, current_mode, current_row, error_number;
|
||||||
int column_position, c, done, exit_status;
|
int column_position, c, done, exit_status;
|
||||||
@ -121,6 +121,12 @@ int data_encode_blockf(unsigned char source[], int input_length, int subset_sel
|
|||||||
column_position++;
|
column_position++;
|
||||||
c--;
|
c--;
|
||||||
}
|
}
|
||||||
|
if((current_row == 0) && reader) {
|
||||||
|
/* Reader Initialise (4.4.7.3) */
|
||||||
|
blockmatrix[current_row][column_position] = 96; /* FNC3 */
|
||||||
|
column_position++;
|
||||||
|
c--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(gs1 && (source[input_position] == '[')) {
|
if(gs1 && (source[input_position] == '[')) {
|
||||||
@ -578,7 +584,7 @@ int codablock(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||||||
int subset_selector[44], row_indicator[44], row_check[44];
|
int subset_selector[44], row_indicator[44], row_check[44];
|
||||||
long int k1_sum, k2_sum;
|
long int k1_sum, k2_sum;
|
||||||
int k1_check, k2_check;
|
int k1_check, k2_check;
|
||||||
int gs1;
|
int gs1, reader;
|
||||||
|
|
||||||
error_number = 0;
|
error_number = 0;
|
||||||
input_length = length;
|
input_length = length;
|
||||||
@ -590,6 +596,11 @@ int codablock(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(symbol->input_mode == GS1_MODE) { gs1 = 1; } else { gs1 = 0; }
|
if(symbol->input_mode == GS1_MODE) { gs1 = 1; } else { gs1 = 0; }
|
||||||
|
if(symbol->output_options & READER_INIT) { reader = 1; } else { reader = 0; }
|
||||||
|
if((gs1 == 1) && (reader == 1)) {
|
||||||
|
strcpy(symbol->errtxt, "Cannot encode GS1 data and Reader Initialise in the same symbol");
|
||||||
|
return ERROR_INVALID_OPTION;
|
||||||
|
}
|
||||||
|
|
||||||
/* Make a guess at how many characters will be needed to encode the data */
|
/* Make a guess at how many characters will be needed to encode the data */
|
||||||
estimate_codelength = 0.0;
|
estimate_codelength = 0.0;
|
||||||
@ -622,7 +633,7 @@ int codablock(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Encode the data */
|
/* Encode the data */
|
||||||
error_number = data_encode_blockf(source, input_length, subset_selector, blockmatrix, &columns_needed, &rows_needed, &final_mode, gs1);
|
error_number = data_encode_blockf(source, input_length, subset_selector, blockmatrix, &columns_needed, &rows_needed, &final_mode, gs1, reader);
|
||||||
if(error_number > 0) {
|
if(error_number > 0) {
|
||||||
if(error_number == ERROR_TOO_LONG) {
|
if(error_number == ERROR_TOO_LONG) {
|
||||||
strcpy(symbol->errtxt, "Input data too long");
|
strcpy(symbol->errtxt, "Input data too long");
|
||||||
|
@ -369,6 +369,17 @@ int dm200encode(struct zint_symbol *symbol, unsigned char source[], unsigned cha
|
|||||||
if(debug) printf("FN1 ");
|
if(debug) printf("FN1 ");
|
||||||
} /* FNC1 */
|
} /* FNC1 */
|
||||||
|
|
||||||
|
if(symbol->output_options & READER_INIT) {
|
||||||
|
if(gs1) {
|
||||||
|
strcpy(symbol->errtxt, "Cannot encode in GS1 mode and Reader Initialisation at the same time");
|
||||||
|
return ERROR_INVALID_OPTION;
|
||||||
|
} else {
|
||||||
|
target[tp] = 234; tp++; /* Reader Programming */
|
||||||
|
concat(binary, " ");
|
||||||
|
if(debug) printf("RP ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while (sp < inputlen) {
|
while (sp < inputlen) {
|
||||||
|
|
||||||
current_mode = next_mode;
|
current_mode = next_mode;
|
||||||
|
@ -330,7 +330,7 @@ void add_shift_char(char binary[], int shifty)
|
|||||||
if(glyph & 0x01) { concat(binary, "1"); } else { concat(binary, "0"); }
|
if(glyph & 0x01) { concat(binary, "1"); } else { concat(binary, "0"); }
|
||||||
}
|
}
|
||||||
|
|
||||||
int gm_encode(int gbdata[], int length, char binary[])
|
int gm_encode(int gbdata[], int length, char binary[], int reader)
|
||||||
{
|
{
|
||||||
/* Create a binary stream representation of the input data.
|
/* Create a binary stream representation of the input data.
|
||||||
7 sets are defined - Chinese characters, Numerals, Lower case letters, Upper case letters,
|
7 sets are defined - Chinese characters, Numerals, Lower case letters, Upper case letters,
|
||||||
@ -350,6 +350,10 @@ int gm_encode(int gbdata[], int length, char binary[])
|
|||||||
last_mode = 0;
|
last_mode = 0;
|
||||||
number_pad_posn = 0;
|
number_pad_posn = 0;
|
||||||
|
|
||||||
|
if(reader) {
|
||||||
|
concat(binary, "1010"); /* FNC3 - Reader Initialisation */
|
||||||
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
next_mode = seek_forward(gbdata, length, sp, current_mode);
|
next_mode = seek_forward(gbdata, length, sp, current_mode);
|
||||||
|
|
||||||
@ -908,7 +912,7 @@ int grid_matrix(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||||||
int x, y, i, j, glyph;
|
int x, y, i, j, glyph;
|
||||||
char binary[9300];
|
char binary[9300];
|
||||||
int data_cw, input_latch = 0;
|
int data_cw, input_latch = 0;
|
||||||
int word[1460], data_max;
|
int word[1460], data_max, reader = 0;
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
int utfdata[length + 1];
|
int utfdata[length + 1];
|
||||||
@ -955,7 +959,9 @@ int grid_matrix(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
error_number = gm_encode(gbdata, length, binary);
|
if(symbol->output_options & READER_INIT) reader = 1;
|
||||||
|
|
||||||
|
error_number = gm_encode(gbdata, length, binary, reader);
|
||||||
if(error_number != 0) {
|
if(error_number != 0) {
|
||||||
strcpy(symbol->errtxt, "Input data too long");
|
strcpy(symbol->errtxt, "Input data too long");
|
||||||
return error_number;
|
return error_number;
|
||||||
|
@ -577,6 +577,13 @@ int maxicode(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||||||
}
|
}
|
||||||
memset(maxi_codeword, 0, sizeof(maxi_codeword));
|
memset(maxi_codeword, 0, sizeof(maxi_codeword));
|
||||||
|
|
||||||
|
if(symbol->output_options & READER_INIT) { mode = 6; }
|
||||||
|
|
||||||
|
if((mode == 6) && (symbol->input_mode == GS1_MODE)) {
|
||||||
|
strcpy(symbol->errtxt, "Cannot encode GS1 and Reader Initialisation at the same time");
|
||||||
|
return ERROR_INVALID_OPTION;
|
||||||
|
}
|
||||||
|
|
||||||
if(mode == -1) { /* If mode is unspecified */
|
if(mode == -1) { /* If mode is unspecified */
|
||||||
lp = strlen(symbol->primary);
|
lp = strlen(symbol->primary);
|
||||||
if(lp == 0) {
|
if(lp == 0) {
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
symbol->option_2 is used to adjust the width of the resulting symbol (i.e. the
|
symbol->option_2 is used to adjust the width of the resulting symbol (i.e. the
|
||||||
number of codeword columns not including row start and end data) */
|
number of codeword columns not including row start and end data) */
|
||||||
|
|
||||||
/* @(#) $Id: pdf417.c,v 1.16 2009/11/17 22:36:04 hooper114 Exp $ */
|
/* @(#) $Id: pdf417.c,v 1.17 2009/12/04 23:18:48 hooper114 Exp $ */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -482,6 +482,10 @@ int pdf417(struct zint_symbol *symbol, unsigned char chaine[], int length)
|
|||||||
/* 541 - now compress the data */
|
/* 541 - now compress the data */
|
||||||
indexchaine = 0;
|
indexchaine = 0;
|
||||||
mclength = 0;
|
mclength = 0;
|
||||||
|
if(symbol->output_options & READER_INIT) {
|
||||||
|
chainemc[mclength] = 921; /* Reader Initialisation */
|
||||||
|
mclength++;
|
||||||
|
}
|
||||||
for(i = 0; i < indexliste; i++) {
|
for(i = 0; i < indexliste; i++) {
|
||||||
switch(liste[1][i]) {
|
switch(liste[1][i]) {
|
||||||
case TEX: /* 547 - text mode */
|
case TEX: /* 547 - text mode */
|
||||||
@ -807,6 +811,10 @@ int micro_pdf417(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||||||
/* 541 - now compress the data */
|
/* 541 - now compress the data */
|
||||||
indexchaine = 0;
|
indexchaine = 0;
|
||||||
mclength = 0;
|
mclength = 0;
|
||||||
|
if(symbol->output_options & READER_INIT) {
|
||||||
|
chainemc[mclength] = 921; /* Reader Initialisation */
|
||||||
|
mclength++;
|
||||||
|
}
|
||||||
for(i = 0; i < indexliste; i++) {
|
for(i = 0; i < indexliste; i++) {
|
||||||
switch(liste[1][i]) {
|
switch(liste[1][i]) {
|
||||||
case TEX: /* 547 - text mode */
|
case TEX: /* 547 - text mode */
|
||||||
|
Loading…
Reference in New Issue
Block a user