From b7b756445702e6ff830a6bec08f6e32afcac5225 Mon Sep 17 00:00:00 2001 From: Harald Oehlmann Date: Tue, 18 Aug 2015 13:50:42 +0200 Subject: [PATCH] Make command line version compile with MS-VC6 and QT-Version with MS-VC8 --- backend/2of5.c | 1 + backend/auspost.c | 3 ++ backend/aztec.c | 6 ++- backend/gridmtx.c | 3 +- backend/library.c | 5 ++- backend/png.c | 15 ++++--- backend/qr.c | 22 ++++++--- backend_qt4/backend_qt4.pro | 31 ++++++++----- backend_qt4/backend_vc8.pro | 9 ++-- frontend_qt4/exportwindow.cpp | 7 ++- frontend_qt4/frontend_qt4.pro | 38 +++++++++++++--- frontend_qt4/grpDM.ui | 85 +++++++++++++++++++++++++++++++++++ frontend_qt4/mainwindow.cpp | 6 +++ win32/libzint.vcproj | 19 ++++---- 14 files changed, 198 insertions(+), 52 deletions(-) diff --git a/backend/2of5.c b/backend/2of5.c index f8ee1cba..f71a9f43 100644 --- a/backend/2of5.c +++ b/backend/2of5.c @@ -36,6 +36,7 @@ #include "common.h" #ifdef _MSC_VER #include +#define inline _inline #endif static const char *C25MatrixTable[10] = {"113311", "311131", "131131", "331111", "113131", "313111", diff --git a/backend/auspost.c b/backend/auspost.c index adfacd7f..fbdd07b6 100644 --- a/backend/auspost.c +++ b/backend/auspost.c @@ -53,6 +53,9 @@ static const char *AusBarTable[64] = {"000", "001", "002", "003", "010", "011", #include #include "common.h" #include "reedsol.h" +#ifdef _MSC_VER +#define inline _inline +#endif static inline char convert_pattern(char data, int shift) { diff --git a/backend/aztec.c b/backend/aztec.c index 38452987..581ac65f 100644 --- a/backend/aztec.c +++ b/backend/aztec.c @@ -679,6 +679,8 @@ int aztec(struct zint_symbol *symbol, unsigned char source[], int length) unsigned char local_source[length + 1]; #else unsigned char* local_source = (unsigned char*)_alloca(length + 1); + unsigned int* data_part; + unsigned int* ecc_part; #endif memset(binary_string,0,20000); @@ -1014,8 +1016,8 @@ int aztec(struct zint_symbol *symbol, unsigned char source[], int length) #ifndef _MSC_VER unsigned int data_part[data_blocks + 3], ecc_part[ecc_blocks + 3]; #else - unsigned int* data_part = (unsigned int*)_alloca((data_blocks + 3) * sizeof(unsigned int)); - unsigned int* ecc_part = (unsigned int*)_alloca((ecc_blocks + 3) * sizeof(unsigned int)); + data_part = (unsigned int*)_alloca((data_blocks + 3) * sizeof(unsigned int)); + ecc_part = (unsigned int*)_alloca((ecc_blocks + 3) * sizeof(unsigned int)); #endif /* Copy across data into separate integers */ memset(data_part,0,(data_blocks + 2)*sizeof(int)); diff --git a/backend/gridmtx.c b/backend/gridmtx.c index 928373aa..67266ddd 100644 --- a/backend/gridmtx.c +++ b/backend/gridmtx.c @@ -927,6 +927,7 @@ int grid_matrix(struct zint_symbol *symbol, unsigned char source[], int length) int utfdata[length + 1]; int gbdata[length + 1]; #else + char* grid; int* utfdata = (int *)_alloca((length + 1) * sizeof(int)); int* gbdata = (int *)_alloca((length + 1) * sizeof(int)); #endif @@ -1050,7 +1051,7 @@ int grid_matrix(struct zint_symbol *symbol, unsigned char source[], int length) #ifndef _MSC_VER char grid[size * size]; #else - char* grid = (char *)_alloca((size * size) * sizeof(char)); + grid = (char *)_alloca((size * size) * sizeof(char)); #endif for(x = 0; x < size; x++) { diff --git a/backend/library.c b/backend/library.c index c3b83d29..68a9ab61 100755 --- a/backend/library.c +++ b/backend/library.c @@ -596,6 +596,9 @@ int reduced_charset(struct zint_symbol *symbol, unsigned char *source, int lengt int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *source, int length) { int error_number, error_buffer, i; +#ifdef _MSC_VER + unsigned char* local_source; +#endif error_number = 0; if(length == 0) { @@ -613,7 +616,7 @@ int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *source, int lengt #ifndef _MSC_VER unsigned char local_source[length + 1]; #else - unsigned char* local_source = (unsigned char*)_alloca(length + 1); + local_source = (unsigned char*)_alloca(length + 1); #endif /* First check the symbology field */ diff --git a/backend/png.c b/backend/png.c index 5da891f1..c5356356 100644 --- a/backend/png.c +++ b/backend/png.c @@ -84,18 +84,19 @@ int png_pixel_plot(struct zint_symbol *symbol, int image_height, int image_width { struct mainprog_info_type wpng_info; struct mainprog_info_type *graphic; + png_structp png_ptr; + png_infop info_ptr; + unsigned char *image_data; + int i, row, column, errno; + int fgred, fggrn, fgblu, bgred, bggrn, bgblu; #ifndef _MSC_VER unsigned char outdata[image_width * 3]; #else unsigned char* outdata = (unsigned char*)_alloca(image_width * 3); #endif - png_structp png_ptr; - png_infop info_ptr; + graphic = &wpng_info; - unsigned char *image_data; - int i, row, column, errno; - int fgred, fggrn, fgblu, bgred, bggrn, bgblu; switch(rotate_angle) { case 0: @@ -691,7 +692,7 @@ void to_latin1(unsigned char source[], unsigned char preprocessed[]) j = 0; i = 0; - do { + while (i < input_length) { if(source[i] < 128) { preprocessed[j] = source[i]; j++; @@ -708,7 +709,7 @@ void to_latin1(unsigned char source[], unsigned char preprocessed[]) i += 2; } } - } while (i < input_length); + } preprocessed[j] = '\0'; return; diff --git a/backend/qr.c b/backend/qr.c index 5dbf2eca..b611c9d2 100644 --- a/backend/qr.c +++ b/backend/qr.c @@ -771,6 +771,8 @@ int evaluate(unsigned char *grid, int size, int pattern) int dark_mods; int percentage, k, k2; char str[15]; + int m; + int smallest; #ifndef _MSC_VER char local[size * size]; @@ -987,7 +989,7 @@ int evaluate(unsigned char *grid, int size, int pattern) } } percentage = 100 * (dark_mods / (size * size)); - int m=0; + m=0; for(x = 0; x < 100; x+=5) { if(x 35) { strcpy(symbol->errtxt, "Input data too long"); @@ -2384,7 +2392,7 @@ int microqr(struct zint_symbol *symbol, unsigned char source[], int length) #ifndef _MSC_VER unsigned char grid[size * size]; #else - unsigned char* grid = (unsigned char *)_alloca((size * size) * sizeof(unsigned char)); + grid = (unsigned char *)_alloca((size * size) * sizeof(unsigned char)); #endif for(i = 0; i < size; i++) { diff --git a/backend_qt4/backend_qt4.pro b/backend_qt4/backend_qt4.pro index 6fbfd44a..7347c790 100644 --- a/backend_qt4/backend_qt4.pro +++ b/backend_qt4/backend_qt4.pro @@ -1,6 +1,13 @@ + TEMPLATE = lib -CONFIG += dll + +# My qt is configured for static build: +# http://qt-project.org/wiki/Build_Standalone_Qt_Application_for_Windows +CONFIG += staticlib + +# for dynamic build enable this: +#CONFIG += dll macx{ CONFIG -= dll @@ -12,11 +19,12 @@ TARGET = QtZint INCLUDEPATH += ../backend #EDIT THIS !!!! -DEFINES += NO_PNG NO_QR ZINT_VERSION="2.3.0" +DEFINES += ZINT_VERSION="\\\"2.3.0\\\"" NO_PNG !contains(DEFINES, NO_PNG) { - SOURCES += ../backend/png.c - LIBS += -lpng + LIBS += -llibpng + INCLUDEPATH += ../../../support/lpng169 + QMAKE_LIBDIR+=../../../support/lpng169/projects/visualc71/Win32_LIB_Release ../../../support/lpng169/projects/visualc71/Win32_LIB_Release/ZLib } contains(DEFINES, QR_SYSTEM){ @@ -49,14 +57,13 @@ HEADERS += ../backend/aztec.h \ ../backend/code49.h \ ../backend/common.h \ ../backend/composite.h \ - ../backend/dm200.h \ ../backend/dmatrix.h \ ../backend/font.h \ + ../backend/gridmtx.h \ ../backend/gs1.h \ ../backend/large.h \ ../backend/maxicode.h \ ../backend/maxipng.h \ - ../backend/micqr.h \ ../backend/pdf417.h \ ../backend/reedsol.h \ ../backend/rss.h \ @@ -67,27 +74,26 @@ HEADERS += ../backend/aztec.h \ SOURCES += ../backend/2of5.c \ ../backend/auspost.c \ ../backend/aztec.c \ - ../backend/blockf.c \ ../backend/code.c \ ../backend/code128.c \ ../backend/code16k.c \ ../backend/code49.c \ ../backend/common.c \ ../backend/composite.c \ - ../backend/dm200.c \ ../backend/dmatrix.c \ + ../backend/gridmtx.c \ ../backend/gs1.c \ ../backend/imail.c \ ../backend/large.c \ ../backend/library.c \ ../backend/maxicode.c \ ../backend/medical.c \ - ../backend/micqr.c \ ../backend/pdf417.c \ ../backend/plessey.c \ ../backend/postal.c \ ../backend/ps.c \ ../backend/reedsol.c \ + ../backend/render.c \ ../backend/rss.c \ ../backend/svg.c \ ../backend/telepen.c \ @@ -95,16 +101,19 @@ SOURCES += ../backend/2of5.c \ ../backend/qr.c \ ../backend/dllversion.c \ ../backend/code1.c \ + ../backend/png.c \ qzint.cpp VERSION = 2.3.0 #DESTDIR = . -include.path = $$[ZINT_INSTALL_HEADERS] +#include.path = $$[ZINT_INSTALL_HEADERS] +include.path = inst/include include.files = ../backend/zint.h qzint.h -target.path = $$[ZINT_INSTALL_LIBS] +#target.path = $$[ZINT_INSTALL_LIBS] +target.path = inst/lib INSTALLS += target include diff --git a/backend_qt4/backend_vc8.pro b/backend_qt4/backend_vc8.pro index 1342100e..e5564faa 100644 --- a/backend_qt4/backend_vc8.pro +++ b/backend_qt4/backend_vc8.pro @@ -9,9 +9,9 @@ VERSION = 2.3.0 QMAKE_CFLAGS += /TP /wd4018 /wd4244 /wd4305 QMAKE_CXXFLAGS += /TP /wd4018 /wd4244 /wd4305 -INCLUDEPATH += ../backend d:\opt\include +INCLUDEPATH += ../backend d:\\opt\\include -DEFINES += _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNINGS ZINT_VERSION=\\\"$$VERSION\\\" +DEFINES += _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNINGS ZINT_VERSION=\\\"$$VERSION\\\" include="" !contains(DEFINES, NO_PNG) { SOURCES += ../backend/png.c @@ -22,7 +22,6 @@ HEADERS += ../backend/aztec.h \ ../backend/code49.h \ ../backend/common.h \ ../backend/composite.h \ - ../backend/dm200.h \ ../backend/dmatrix.h \ ../backend/font.h \ ../backend/gb2312.h \ @@ -43,7 +42,6 @@ HEADERS += ../backend/aztec.h \ SOURCES += ../backend/2of5.c \ ../backend/auspost.c \ ../backend/aztec.c \ - ../backend/blockf.c \ ../backend/code.c \ ../backend/code1.c \ ../backend/code128.c \ @@ -51,7 +49,6 @@ SOURCES += ../backend/2of5.c \ ../backend/code49.c \ ../backend/common.c \ ../backend/composite.c \ - ../backend/dm200.c \ ../backend/dmatrix.c \ ../backend/gridmtx.c \ ../backend/gs1.c \ @@ -66,9 +63,9 @@ SOURCES += ../backend/2of5.c \ ../backend/ps.c \ ../backend/qr.c \ ../backend/reedsol.c \ + ../backend/render.c \ ../backend/rss.c \ ../backend/svg.c \ ../backend/telepen.c \ ../backend/upcean.c \ qzint.cpp - diff --git a/frontend_qt4/exportwindow.cpp b/frontend_qt4/exportwindow.cpp index 40c27b6e..38c51605 100644 --- a/frontend_qt4/exportwindow.cpp +++ b/frontend_qt4/exportwindow.cpp @@ -72,9 +72,14 @@ void ExportWindow::process() inputpos = 0; switch(cmbFileFormat->currentIndex()) { - case 0: suffix = ".png"; break; +#ifdef NO_PNG + case 0: suffix = ".eps"; break; + case 1: suffix = ".svg"; break; +#else + case 0: suffix = ".png"; break; case 1: suffix = ".eps"; break; case 2: suffix = ".svg"; break; +#endif } for(i = 0; i < lines; i++) { diff --git a/frontend_qt4/frontend_qt4.pro b/frontend_qt4/frontend_qt4.pro index 2faf3233..fa75cfff 100644 --- a/frontend_qt4/frontend_qt4.pro +++ b/frontend_qt4/frontend_qt4.pro @@ -4,21 +4,31 @@ TEMPLATE = app -TARGET = +TARGET = qtZint DEPENDPATH += . debug release INCLUDEPATH += . +DEFINES += NO_PNG # Input -HEADERS += barcodeitem.h mainwindow.h -FORMS += grpAztec.ui \ +HEADERS += barcodeitem.h \ + datawindow.h \ + exportwindow.h \ + mainwindow.h \ + sequencewindow.h + +FORMS += extData.ui \ + extExport.ui \ + extSequence.ui \ + grpAztec.ui \ grpC128.ui \ grpC16k.ui \ grpC39.ui \ grpC49.ui \ grpChannel.ui \ - grpCodablock.ui \ grpCodeOne.ui \ + grpDBExtend.ui \ grpDM.ui \ + grpGrid.ui \ grpMaxicode.ui \ grpMicroPDF.ui \ grpMQR.ui \ @@ -26,6 +36,24 @@ FORMS += grpAztec.ui \ grpPDF417.ui \ grpQR.ui \ mainWindow.ui + +SOURCES += barcodeitem.cpp \ + datawindow.cpp \ + exportwindow.cpp \ + main.cpp \ + mainwindow.cpp \ + sequencewindow.cpp + TRANSLATIONS = frontend_de.ts -SOURCES += barcodeitem.cpp main.cpp mainwindow.cpp + RESOURCES += resources.qrc + +# Static target following http://qt-project.org/wiki/Build_Standalone_Qt_Application_for_Windows +CONFIG += static + +CONFIG += warn_on thread qt uitools + +INCLUDEPATH += ../backend_qt4 ../backend + +LIBS += -lqtzint -lQtCore +QMAKE_LIBDIR += ../backend_qt4/release \ No newline at end of file diff --git a/frontend_qt4/grpDM.ui b/frontend_qt4/grpDM.ui index 95054f95..fde3ee68 100644 --- a/frontend_qt4/grpDM.ui +++ b/frontend_qt4/grpDM.ui @@ -207,6 +207,91 @@ 16 x 48 + + + 8 x 48 + + + + + 8 x 64 + + + + + 12 x 48 + + + + + 12 x 64 + + + + + 16 x 64 + + + + + 24 x 32 + + + + + 24 x 40 + + + + + 24 x 48 + + + + + 24 x 64 + + + + + 26 x 32 + + + + + 26 x 40 + + + + + 26 x 48 + + + + + 26 x 64 + + + + + 36 x 120 + + + + + 36 x 144 + + + + + 72 x 120 + + + + + 72 x 144 + + diff --git a/frontend_qt4/mainwindow.cpp b/frontend_qt4/mainwindow.cpp index a3a0bd51..8e405f4a 100644 --- a/frontend_qt4/mainwindow.cpp +++ b/frontend_qt4/mainwindow.cpp @@ -146,9 +146,15 @@ bool MainWindow::save() { bool status; +#ifdef NO_PNG + QString fileName = QFileDialog::getSaveFileName(this, + tr("Save Barcode Image"), ".", + tr("Encapsulated Post Script (*.eps);;Scalable Vector Graphic (*.svg)")); +#else QString fileName = QFileDialog::getSaveFileName(this, tr("Save Barcode Image"), ".", tr("Portable Network Graphic (*.png);;Encapsulated Post Script (*.eps);;Scalable Vector Graphic (*.svg)")); +#endif if (fileName.isEmpty()) return false; diff --git a/win32/libzint.vcproj b/win32/libzint.vcproj index f7344b82..09b8f764 100644 --- a/win32/libzint.vcproj +++ b/win32/libzint.vcproj @@ -41,8 +41,8 @@ - -