mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Add Code One support
This commit is contained in:
parent
7ad339627c
commit
2145673ce4
@ -8,7 +8,7 @@ find_package(Qr)
|
||||
set(zint_COMMON_SRCS common.c library.c ps.c large.c reedsol.c gs1.c svg.c)
|
||||
set(zint_ONEDIM_SRCS code.c code128.c 2of5.c upcean.c telepen.c medical.c plessey.c rss.c)
|
||||
set(zint_POSTAL_SRCS postal.c auspost.c imail.c)
|
||||
set(zint_TWODIM_SRCS code16k.c blockf.c dmatrix.c dm200.c pdf417.c qr.c micqr.c maxicode.c composite.c aztec.c code49.c)
|
||||
set(zint_TWODIM_SRCS code16k.c blockf.c dmatrix.c dm200.c pdf417.c qr.c micqr.c maxicode.c composite.c aztec.c code49.c code1.c)
|
||||
set(zint_SRCS ${zint_COMMON_SRCS} ${zint_ONEDIM_SRCS} ${zint_POSTAL_SRCS} ${zint_TWODIM_SRCS} )
|
||||
|
||||
if(PNG_FOUND)
|
||||
|
@ -25,8 +25,8 @@ ONEDIM:= code.c code128.c 2of5.c upcean.c telepen.c medical.c plessey.c rss.c
|
||||
ONEDIM_OBJ:= code.o code128.o 2of5.o upcean.o telepen.o medical.o plessey.o rss.o
|
||||
POSTAL:= postal.c auspost.c imail.c
|
||||
POSTAL_OBJ:= postal.o auspost.o imail.o
|
||||
TWODIM:= code16k.c blockf.c dmatrix.c dm200.c pdf417.c qr.c maxicode.c composite.c aztec.c micqr.c code49.c
|
||||
TWODIM_OBJ:= code16k.o blockf.o dmatrix.o dm200.o pdf417.o qr.o maxicode.o composite.o aztec.o micqr.o code49.o
|
||||
TWODIM:= code16k.c blockf.c dmatrix.c dm200.c pdf417.c qr.c maxicode.c composite.c aztec.c micqr.c code49.c code1.c
|
||||
TWODIM_OBJ:= code16k.o blockf.o dmatrix.o dm200.o pdf417.o qr.o maxicode.o composite.o aztec.o micqr.o code49.o code1.o
|
||||
LIBS:= `libpng12-config --I_opts --L_opts --ldflags` -lz -lm
|
||||
|
||||
ifeq ($(NO_QR),true)
|
||||
@ -36,7 +36,7 @@ DEFINES:=
|
||||
LIBS+= -lqrencode
|
||||
endif
|
||||
|
||||
libzint: code.c code128.c 2of5.c upcean.c medical.c telepen.c plessey.c postal.c auspost.c imail.c code16k.c dmatrix.c dm200.c reedsol.c pdf417.c maxicode.c rss.c common.c png.c library.c ps.c qr.c large.c composite.c aztec.c blockf.c micqr.c gs1.c svg.c code49.c
|
||||
libzint: code.c code128.c 2of5.c upcean.c medical.c telepen.c plessey.c postal.c auspost.c imail.c code16k.c dmatrix.c dm200.c reedsol.c pdf417.c maxicode.c rss.c common.c png.c library.c ps.c qr.c large.c composite.c aztec.c blockf.c micqr.c gs1.c svg.c code49.c code1.c
|
||||
$(CC) -Wall -fPIC $(CFLAGS) $(ZINT_VERSION) -c $(ONEDIM)
|
||||
$(CC) -Wall -fPIC $(CFLAGS) $(ZINT_VERSION) -c $(POSTAL)
|
||||
$(CC) -Wall -fPIC $(DEFINES) $(CFLAGS) $(ZINT_VERSION) -c $(TWODIM)
|
||||
|
1316
backend/code1.c
Normal file
1316
backend/code1.c
Normal file
File diff suppressed because it is too large
Load Diff
61
backend/code1.h
Normal file
61
backend/code1.h
Normal file
@ -0,0 +1,61 @@
|
||||
/* code1.h - Lookup info for USS Code One */
|
||||
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2009 Robin Stuart <robin@zint.org.uk>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
static int c40_shift[] = {
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 };
|
||||
|
||||
static int c40_value[] = {
|
||||
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,
|
||||
3,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,4,5,6,7,8,9,10,11,12,13,
|
||||
15,16,17,18,19,20,21,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,
|
||||
22,23,24,25,26,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31 };
|
||||
|
||||
static int text_shift[] = {
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
2, 2, 2, 2, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3 };
|
||||
|
||||
static int text_value[] = {
|
||||
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,
|
||||
3,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,4,5,6,7,8,9,10,11,12,13,
|
||||
15,16,17,18,19,20,21,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,
|
||||
22,23,24,25,26,0,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,27,28,29,30,31 };
|
||||
|
||||
static int c1_height[] = { 16, 22, 28, 40, 52, 70, 104, 148 };
|
||||
static int c1_width[] = { 18, 22, 32, 42, 54, 76, 98, 134 };
|
||||
static int c1_data_length[] = { 10, 19, 44, 91, 182, 370, 732, 1480 };
|
||||
static int c1_ecc_length[] = { 10, 16, 26, 44, 70, 140, 280, 560 };
|
||||
static int c1_blocks[] = { 1, 1, 1, 1, 1, 2, 4, 8 };
|
||||
static int c1_data_blocks[] = { 10, 19, 44, 91, 182, 185, 183, 185 };
|
||||
static int c1_ecc_blocks[] = { 10, 16, 26, 44, 70, 70, 70, 70 };
|
||||
static int c1_grid_width[] = { 4, 5, 7, 9, 12, 17, 22, 30 };
|
||||
static int c1_grid_height[] = { 5, 7, 10, 15, 21, 30, 46, 68 };
|
||||
|
||||
#define C1_ASCII 1
|
||||
#define C1_C40 2
|
||||
#define C1_DECIMAL 3
|
||||
#define C1_TEXT 4
|
||||
#define C1_EDI 5
|
||||
#define C1_BYTE 6
|
@ -259,3 +259,24 @@ int roundup(float input)
|
||||
return integer_part;
|
||||
}
|
||||
|
||||
int istwodigits(unsigned char source[], int position)
|
||||
{
|
||||
if((source[position] >= '0') && (source[position] <= '9')) {
|
||||
if((source[position + 1] >= '0') && (source[position + 1] <= '9')) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
float froundup(float input)
|
||||
{
|
||||
float fraction, output = 0.0;
|
||||
|
||||
fraction = input - (int)input;
|
||||
if(fraction > 0.01) { output = (input - fraction) + 1.0; } else { output = input; }
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
@ -58,6 +58,8 @@ extern int roundup(float input);
|
||||
extern int module_is_set(struct zint_symbol *symbol, int y_coord, int x_coord);
|
||||
extern void set_module(struct zint_symbol *symbol, int y_coord, int x_coord);
|
||||
extern void unset_module(struct zint_symbol *symbol, int y_coord, int x_coord);
|
||||
extern int istwodigits(unsigned char source[], int position);
|
||||
extern float froundup(float input);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
@ -125,6 +125,7 @@ extern int korea_post(struct zint_symbol *symbol, unsigned char source[]); /* Ko
|
||||
extern int japan_post(struct zint_symbol *symbol, unsigned char source[]); /* Japanese Post */
|
||||
extern int code_49(struct zint_symbol *symbol, unsigned char source[]); /* Code 49 */
|
||||
extern int channel_code(struct zint_symbol *symbol, unsigned char source[]); /* Channel Code */
|
||||
extern int code_one(struct zint_symbol *symbol, unsigned char source[]); /* Code One */
|
||||
|
||||
#ifndef NO_PNG
|
||||
int png_handle(struct zint_symbol *symbol, int rotate_angle);
|
||||
@ -438,7 +439,7 @@ int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *source)
|
||||
if(symbol->symbology == 111) { symbol->symbology = BARCODE_HIBC_BLOCKF; }
|
||||
if((symbol->symbology >= 112) && (symbol->symbology <= 127)) { strcpy(symbol->errtxt, "Symbology out of range, using Code 128"); symbol->symbology = BARCODE_CODE128; error_number = WARN_INVALID_OPTION; }
|
||||
/* Everything from 128 up is Zint-specific */
|
||||
if(symbol->symbology >= 141) { strcpy(symbol->errtxt, "Symbology out of range, using Code 128"); symbol->symbology = BARCODE_CODE128; error_number = WARN_INVALID_OPTION; }
|
||||
if(symbol->symbology >= 142) { strcpy(symbol->errtxt, "Symbology out of range, using Code 128"); symbol->symbology = BARCODE_CODE128; error_number = WARN_INVALID_OPTION; }
|
||||
|
||||
if(error_number > 4) {
|
||||
error_tag(symbol->errtxt, error_number);
|
||||
@ -575,6 +576,7 @@ int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *source)
|
||||
case BARCODE_JAPANPOST: error_number = japan_post(symbol, preprocessed); break;
|
||||
case BARCODE_CODE49: error_number = code_49(symbol, preprocessed); break;
|
||||
case BARCODE_CHANNEL: error_number = channel_code(symbol, preprocessed); break;
|
||||
case BARCODE_CODEONE: error_number = code_one(symbol, preprocessed); break;
|
||||
}
|
||||
|
||||
if((symbol->symbology == BARCODE_CODE128) || (symbol->symbology == BARCODE_CODE128B)) {
|
||||
|
@ -138,6 +138,7 @@ struct zint_symbol {
|
||||
#define BARCODE_RSS14_OMNI_CC 138
|
||||
#define BARCODE_RSS_EXPSTACK_CC 139
|
||||
#define BARCODE_CHANNEL 140
|
||||
#define BARCODE_CODEONE 141
|
||||
|
||||
#define BARCODE_NO_ASCII 1
|
||||
#define BARCODE_BIND 2
|
||||
|
@ -94,6 +94,7 @@ SOURCES += ../backend/2of5.c \
|
||||
../backend/upcean.c \
|
||||
../backend/qr.c \
|
||||
../backend/dllversion.c \
|
||||
../backend/code1.c \
|
||||
qzint.cpp
|
||||
|
||||
VERSION = 2.1.3
|
||||
|
@ -291,6 +291,7 @@ void QZint::render(QPainter & painter, const QRectF & paintRect, AspectRatioMode
|
||||
|
||||
painter.save();
|
||||
painter.setClipRect(paintRect,Qt::IntersectClip);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
qreal xtr=paintRect.x();
|
||||
qreal ytr=paintRect.y();
|
||||
|
||||
|
@ -36,6 +36,8 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags fl)
|
||||
"Aztec Code",
|
||||
"Aztec Runes",
|
||||
"Channel Code",
|
||||
"Codabar",
|
||||
"Codablock-F",
|
||||
"Code 11",
|
||||
"Code 128",
|
||||
"Code 16k",
|
||||
@ -49,8 +51,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags fl)
|
||||
"Code 39 Extended",
|
||||
"Code 49",
|
||||
"Code 93",
|
||||
"Codabar",
|
||||
"Codablock-F",
|
||||
"Code One",
|
||||
"Databar",
|
||||
"Databar Expanded",
|
||||
"Databar Expanded Stacked",
|
||||
@ -103,7 +104,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags fl)
|
||||
bstyle->addItem(metaObject()->enumerator(0).key(i));
|
||||
bstyle->setItemText(i,bstyle_text[i]);
|
||||
}
|
||||
bstyle->setCurrentIndex(8);
|
||||
bstyle->setCurrentIndex(10);
|
||||
change_options();
|
||||
update_preview();
|
||||
view->scene()->addItem(&m_bc);
|
||||
|
@ -45,6 +45,8 @@ public:
|
||||
AZTEC =92,
|
||||
AZRUNE =128,
|
||||
CHANNEL =140,
|
||||
CODABAR =18,
|
||||
CODABLOCKF =74,
|
||||
CODE11 =1,
|
||||
CODE128 =20,
|
||||
CODE16K =23,
|
||||
@ -58,8 +60,7 @@ public:
|
||||
EXCODE39 =9,
|
||||
CODE49 =24,
|
||||
CODE93 =25,
|
||||
CODABAR =18,
|
||||
CODABLOCKF =74,
|
||||
CODE_ONE =141,
|
||||
RSS14 =29,
|
||||
RSS_EXP =31,
|
||||
RSS_EXPSTACK =81,
|
||||
|
Loading…
Reference in New Issue
Block a user