diff --git a/backend/CMakeLists.txt b/backend/CMakeLists.txt index 72637e61..26b8b3b9 100644 --- a/backend/CMakeLists.txt +++ b/backend/CMakeLists.txt @@ -7,7 +7,7 @@ find_package(PNG) set(zint_COMMON_SRCS common.c library.c render.c ps.c large.c reedsol.c gs1.c svg.c png.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 dmatrix.c pdf417.c qr.c maxicode.c composite.c aztec.c code49.c code1.c gridmtx.c) +set(zint_TWODIM_SRCS code16k.c dmatrix.c pdf417.c qr.c maxicode.c composite.c aztec.c code49.c code1.c gridmtx.c hanxin.c) set(zint_SRCS ${zint_COMMON_SRCS} ${zint_ONEDIM_SRCS} ${zint_POSTAL_SRCS} ${zint_TWODIM_SRCS} ) if(PNG_FOUND) diff --git a/backend/hanxin.c b/backend/hanxin.c new file mode 100644 index 00000000..91d37ce7 --- /dev/null +++ b/backend/hanxin.c @@ -0,0 +1,47 @@ +/* hanxin.c - Han Xin Code + + libzint - the open source barcode library + Copyright (C) 2009-2016 Robin Stuart + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the project nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + */ + +/* This code attempts to implement Han Xin Code according to AIMD-015:2010 (Rev 0.8) */ + +#include +#include +#include +#ifdef _MSC_VER +#include +#endif +#include "common.h" +#include "reedsol.h" +#include "hanxin.h" + +int han_xin(struct zint_symbol *symbol, const unsigned char source[], int length) { + printf("Sucessfully init HAN XIN\n"); + return ZINT_ERROR_INVALID_OPTION; +} \ No newline at end of file diff --git a/backend/hanxin.h b/backend/hanxin.h new file mode 100644 index 00000000..1b5a7d53 --- /dev/null +++ b/backend/hanxin.h @@ -0,0 +1,49 @@ +/* hanxin.h - definitions for Han Xin code + + libzint - the open source barcode library + Copyright (C) 2009-2016 Robin Stuart + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the project nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + */ + +#ifndef HANXIN_H +#define HANXIN_H + +#ifdef __cplusplus +extern "C" { +#endif + + + + +#ifdef __cplusplus +} +#endif + +#endif /* NEWFILE_H */ + + + diff --git a/backend/library.c b/backend/library.c index 269c1589..f26e6eed 100644 --- a/backend/library.c +++ b/backend/library.c @@ -181,6 +181,7 @@ extern int code_49(struct zint_symbol *symbol, unsigned char source[], const int extern int channel_code(struct zint_symbol *symbol, unsigned char source[], int length); /* Channel Code */ extern int code_one(struct zint_symbol *symbol, unsigned char source[], int length); /* Code One */ extern int grid_matrix(struct zint_symbol *symbol, const unsigned char source[], int length); /* Grid Matrix */ +extern int han_xin(struct zint_symbol * symbol, const unsigned char source[], int length); /* Han Xin */ #ifndef NO_PNG extern int png_handle(struct zint_symbol *symbol, int rotate_angle); @@ -473,6 +474,7 @@ int ZBarcode_ValidID(int symbol_id) { case BARCODE_CHANNEL: case BARCODE_CODEONE: case BARCODE_GRIDMATRIX: + case BARCODE_HANXIN: result = 1; break; } @@ -491,6 +493,8 @@ static int extended_charset(struct zint_symbol *symbol, const unsigned char *sou break; case BARCODE_GRIDMATRIX: error_number = grid_matrix(symbol, source, length); break; + case BARCODE_HANXIN: error_number = han_xin(symbol, source, length); + break; } return error_number; @@ -829,7 +833,17 @@ int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *source, int lengt if (symbol->symbology == 111) { symbol->symbology = BARCODE_HIBC_BLOCKF; } - if ((symbol->symbology >= 113) && (symbol->symbology <= 127)) { + if ((symbol->symbology == 113) || (symbol->symbology == 114)) { + strcpy(symbol->errtxt, "Symbology out of range, using Code 128"); + symbol->symbology = BARCODE_CODE128; + error_number = ZINT_WARN_INVALID_OPTION; + } + if (symbol->symbology == 115) { + strcpy(symbol->errtxt, "Dot Code not supported"); + symbol->symbology = BARCODE_CODE128; + error_number = ZINT_WARN_INVALID_OPTION; + } + if ((symbol->symbology >= 117) && (symbol->symbology <= 127)) { strcpy(symbol->errtxt, "Symbology out of range, using Code 128"); symbol->symbology = BARCODE_CODE128; error_number = ZINT_WARN_INVALID_OPTION; @@ -882,6 +896,7 @@ int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *source, int lengt case BARCODE_QRCODE: case BARCODE_MICROQR: case BARCODE_GRIDMATRIX: + case BARCODE_HANXIN: error_number = extended_charset(symbol, local_source, length); break; default: diff --git a/backend/zint.h b/backend/zint.h index f9328442..b3ca2fb2 100644 --- a/backend/zint.h +++ b/backend/zint.h @@ -170,6 +170,10 @@ extern "C" { #define BARCODE_HIBC_MICPDF 108 #define BARCODE_HIBC_BLOCKF 110 #define BARCODE_HIBC_AZTEC 112 + + /* Tbarcode 10 codes */ +#define BARCODE_DOTCODE 115 +#define BARCODE_HANXIN 116 /* Zint specific */ #define BARCODE_AZRUNE 128 diff --git a/frontend/main.c b/frontend/main.c index a67c6db4..8b141403 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -48,22 +48,22 @@ void types(void) { "13: EAN 63: AP Standard Customer 106: HIBC PDF417\n" "16: GS1-128 66: AP Reply Paid 108: HIBC MicroPDF417\n" "18: Codabar 67: AP Routing 112: HIBC Aztec Code\n" - "20: Code 128 68: AP Redirection 128: Aztec Runes\n" - "21: Leitcode 69: ISBN 129: Code 23\n" - "22: Identcode 70: RM4SCC 130: Comp EAN\n" - "23: Code 16k 71: Data Matrix 131: Comp GS1-128\n" - "24: Code 49 72: EAN-14 132: Comp DataBar Omni\n" - "25: Code 93 75: NVE-18 133: Comp DataBar Ltd\n" - "28: Flattermarken 76: Japanese Post 134: Comp DataBar ExpOm\n" - "29: GS1 DataBar Omni 77: Korea Post 135: Comp UPC-A\n" - "30: GS1 DataBar Ltd 79: GS1 DataBar Stack 136: Comp UPC-E\n" - "31: GS1 DataBar ExpOm 80: GS1 DataBar Stack Omni 137: Comp DataBar Stack\n" - "32: Telepen Alpha 81: GS1 DataBar ESO 138: Comp DataBar Stack Omni\n" - "34: UPC-A 82: Planet 139: Comp DataBar ESO\n" - "37: UPC-E 84: MicroPDF 140: Channel Code\n" - "40: Postnet 85: USPS OneCode 141: Code One\n" - "47: MSI Plessey 86: UK Plessey 142: Grid Matrix\n" - "49: FIM 87: Telepen Numeric\n" + "20: Code 128 68: AP Redirection 116: Han Xin Code\n" + "21: Leitcode 69: ISBN 128: Aztec Runes\n" + "22: Identcode 70: RM4SCC 129: Code 32\n" + "23: Code 16k 71: Data Matrix 130: Comp EAN\n" + "24: Code 49 72: EAN-14 131: Comp GS1-128\n" + "25: Code 93 75: NVE-18 132: Comp DataBar Omni\n" + "28: Flattermarken 76: Japanese Post 133: Comp DataBar Ltd\n" + "29: GS1 DataBar Omni 77: Korea Post 134: Comp DataBar ExpOm\n" + "30: GS1 DataBar Ltd 79: GS1 DataBar Stack 135: Comp UPC-A\n" + "31: GS1 DataBar ExpOm 80: GS1 DataBar Stack Omni 136: Comp UPC-E\n" + "32: Telepen Alpha 81: GS1 DataBar ESO 137: Comp DataBar Stack\n" + "34: UPC-A 82: Planet 138: Comp DataBar Stack Omni\n" + "37: UPC-E 84: MicroPDF 139: Comp DataBar ESO\n" + "40: Postnet 85: USPS OneCode 140: Channel Code\n" + "47: MSI Plessey 86: UK Plessey 141: Code One\n" + "49: FIM 87: Telepen Numeric 142: Grid Matrix\n" "50: Logmars 89: ITF-14\n" ); } diff --git a/frontend_qt4/mainwindow.cpp b/frontend_qt4/mainwindow.cpp index 8aec13de..9e73b97b 100644 --- a/frontend_qt4/mainwindow.cpp +++ b/frontend_qt4/mainwindow.cpp @@ -68,7 +68,8 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags fl) "GS1 DataBar Omnidirectional", "GS1 DataBar Stacked", "GS1 DataBar Stacked Omnidirectional", - "ITF-14", + "Han Xin Code", + "ITF-14", "International Standard Book Number (ISBN)", "Japanese Postal Barcode", "Korean Postal Barcode", @@ -676,7 +677,7 @@ void MainWindow::update_preview() m_bc.bc.setSymbol(BARCODE_HIBC_AZTEC); break; - case MSI_PLESSEY: + case BARCODE_MSI_PLESSEY: m_bc.bc.setSymbol(BARCODE_MSI_PLESSEY); m_bc.bc.setWidth(m_optionWidget->findChild("cmbMSICheck")->currentIndex()); break; @@ -792,7 +793,10 @@ void MainWindow::update_preview() if(m_optionWidget->findChild("radC49GS1")->isChecked()) m_bc.bc.setInputMode(GS1_MODE); break; - + case BARCODE_HANXIN: + m_bc.bc.setSymbol(BARCODE_HANXIN); + // Space reserved for more options! + break; default: m_bc.bc.setSymbol(metaObject()->enumerator(0).value(bstyle->currentIndex())); break; diff --git a/frontend_qt4/mainwindow.h b/frontend_qt4/mainwindow.h index 425e7faa..8cf10b2a 100644 --- a/frontend_qt4/mainwindow.h +++ b/frontend_qt4/mainwindow.h @@ -74,7 +74,8 @@ public: RSS_LTD =30, RSS14 =29, RSS14STACK =79, - RSS14STACK_OMNI =80, + RSS14STACK_OMNI =80, + HANXIN =116, ITF14 =89, ISBNX =69, JAPANPOST =76,