- Compile-able with MS-VC6

- Compile-able with MS-VC2015+QT5.18
- transbarency in TCL backend
- correct TCL demo
- README changes
This commit is contained in:
Harald Oehlmann 2020-08-04 15:49:25 +02:00
parent 398b1aba2b
commit b78fa8cf2f
7 changed files with 164 additions and 107 deletions

8
README
View File

@ -261,6 +261,14 @@ Bugs:
- Human readable representation: Code128, Code39, Code93 special characters - Human readable representation: Code128, Code39, Code93 special characters
are shown by a blank. are shown by a blank.
- ITF14: Ticket 201: allow bind option - ITF14: Ticket 201: allow bind option
Version 2.9.1 not released jet:
Changes:
- Implement transparency support
- -nobackground option added
- -fg and -bg may contain an alpha channel
- structure zint_symbol may now contain an alpha channel as output
- Added DPD Symbology
Bugs:
CONTACT US CONTACT US
---------- ----------

View File

@ -113,6 +113,11 @@ INTERNAL int ps_plot(struct zint_symbol *symbol) {
int colour_index, colour_rect_counter; int colour_index, colour_rect_counter;
char ps_color[30]; char ps_color[30];
int draw_background = 1; int draw_background = 1;
struct zint_vector_rect *rect;
struct zint_vector_hexagon *hex;
struct zint_vector_circle *circle;
struct zint_vector_string *string;
const char *locale = NULL;
if (strlen(symbol->bgcolour) > 6) { if (strlen(symbol->bgcolour) > 6) {
if ((ctoi(symbol->bgcolour[6]) == 0) && (ctoi(symbol->bgcolour[7]) == 0)) { if ((ctoi(symbol->bgcolour[6]) == 0) && (ctoi(symbol->bgcolour[7]) == 0)) {
@ -120,12 +125,6 @@ INTERNAL int ps_plot(struct zint_symbol *symbol) {
} }
} }
struct zint_vector_rect *rect;
struct zint_vector_hexagon *hex;
struct zint_vector_circle *circle;
struct zint_vector_string *string;
const char *locale = NULL;
if (symbol->output_options & BARCODE_STDOUT) { if (symbol->output_options & BARCODE_STDOUT) {
feps = stdout; feps = stdout;
} else { } else {

View File

@ -132,6 +132,7 @@ INTERNAL int svg_plot(struct zint_symbol *symbol) {
struct zint_vector_string *string; struct zint_vector_string *string;
char colour_code[7]; char colour_code[7];
int html_len;
#ifdef _MSC_VER #ifdef _MSC_VER
char* html_string; char* html_string;
@ -151,7 +152,7 @@ INTERNAL int svg_plot(struct zint_symbol *symbol) {
bg_alpha = (16 * ctoi(symbol->bgcolour[6])) + ctoi(symbol->bgcolour[7]); bg_alpha = (16 * ctoi(symbol->bgcolour[6])) + ctoi(symbol->bgcolour[7]);
} }
int html_len = strlen((char *)symbol->text) + 1; html_len = strlen((char *)symbol->text) + 1;
for (i = 0; i < (int) strlen((char *)symbol->text); i++) { for (i = 0; i < (int) strlen((char *)symbol->text); i++) {
switch(symbol->text[i]) { switch(symbol->text[i]) {

View File

@ -20,6 +20,9 @@
#include <stdio.h> #include <stdio.h>
#include <math.h> #include <math.h>
#include <QFontMetrics> #include <QFontMetrics>
/* the following include was necessary to compile with QT 5.18 on Windows */
/* QT 8.7 did not require it. */
#include <QPainterPath>
namespace Zint { namespace Zint {
static const char* fontstyle = "Arial"; static const char* fontstyle = "Arial";
@ -84,13 +87,8 @@ namespace Zint {
} }
strcpy(m_zintSymbol->fgcolour, m_fgColor.name().toLatin1().right(6)); strcpy(m_zintSymbol->fgcolour, m_fgColor.name().toLatin1().right(6));
if (m_fgColor.alpha() != 0xff) {
strcat(m_zintSymbol->fgcolour, m_fgColor.name(QColor::HexArgb).toLatin1().mid(1,2));
}
strcpy(m_zintSymbol->bgcolour, m_bgColor.name().toLatin1().right(6)); strcpy(m_zintSymbol->bgcolour, m_bgColor.name().toLatin1().right(6));
if (m_bgColor.alpha() != 0xff) {
strcat(m_zintSymbol->bgcolour, m_bgColor.name(QColor::HexArgb).toLatin1().mid(1,2));
}
strcpy(m_zintSymbol->primary, m_primaryMessage.toLatin1().left(127)); strcpy(m_zintSymbol->primary, m_primaryMessage.toLatin1().left(127));
} }

View File

@ -52,7 +52,7 @@ proc Generate {} {
::zintimg blank ::zintimg blank
::zintimg configure -width 0 -height 0 ::zintimg configure -width 0 -height 0
catch { catch {
zint encode [.e get] ::zintimg -barcode [.c get] -scale $sx {*}[.o get]} e] zint encode [.e get] ::zintimg -barcode [.c get] -scale $sx {*}[.o get]
} }
} }
} }

View File

@ -95,6 +95,11 @@
- RSS14Omni-CC -> GS1DataBarStackedOmni-CC - RSS14Omni-CC -> GS1DataBarStackedOmni-CC
- RSSExpandedStacked-CC -> GS1DataBarExpandedStacked-CC - RSSExpandedStacked-CC -> GS1DataBarExpandedStacked-CC
*** Potential incompatibility *** *** Potential incompatibility ***
2020-08-04 2.10.0 HaO
- added symbology "DPDCode"
- Alpha channel support added:
- added option -nobackground
- also allow RRGGBBAA for -fg and -bg options
*/ */
#if defined(__WIN32__) || defined(_WIN32) || defined(WIN32) #if defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
@ -216,6 +221,7 @@ static char *s_code_list[] = {
"GS1DataBarSstackedOmni", "GS1DataBarSstackedOmni",
"GS1DataBarExpandedStacked", "GS1DataBarExpandedStacked",
"Planet", "Planet",
"DPDCode",
"MicroPDF417", "MicroPDF417",
"USPSIntelligentMail", "USPSIntelligentMail",
"Plessey", "Plessey",
@ -313,6 +319,7 @@ static int s_code_number[] = {
BARCODE_DBAR_OMNSTK, BARCODE_DBAR_OMNSTK,
BARCODE_DBAR_EXPSTK, BARCODE_DBAR_EXPSTK,
BARCODE_PLANET, BARCODE_PLANET,
BARCODE_DPD,
BARCODE_MICROPDF417, BARCODE_MICROPDF417,
BARCODE_USPS_IMAIL, BARCODE_USPS_IMAIL,
BARCODE_PLESSEY, BARCODE_PLESSEY,
@ -419,8 +426,9 @@ static char help_message[] = "zint tcl(stub,obj) dll\n"
" -box bool: box around bar code, size set be -border\n" " -box bool: box around bar code, size set be -border\n"
" -height integer: Symbol height in modules\n" " -height integer: Symbol height in modules\n"
" -whitesp integer: horizontal quiet zone in modules\n" " -whitesp integer: horizontal quiet zone in modules\n"
" -fg color: set foreground color as 6 hex rrggbb\n" " -fg color: set foreground color as 6 or 8 hex rrggbbaa\n"
" -bg color: set background color as 6 hex rrggbb\n" " -bg color: set background color as 6 or 8 hex rrggbbaa\n"
" -nobackground bool: set background transparent\n"
" -cols integer: PDF417, Codablock F: number of columns\n" " -cols integer: PDF417, Codablock F: number of columns\n"
" -rows integer: Codablock F: number of rows\n" " -rows integer: Codablock F: number of rows\n"
" -vers integer: Symbology option\n" " -vers integer: Symbology option\n"
@ -624,13 +632,14 @@ static int Encode(Tcl_Interp *interp, int objc,
char *optionList[] = { char *optionList[] = {
"-addongap", "-barcode", "-bg", "-bind", "-bold", "-border", "-box", "-addongap", "-barcode", "-bg", "-bind", "-bold", "-border", "-box",
"-cols", "-dmre", "-dotsize", "-dotty", "-eci", "-fg", "-format", "-cols", "-dmre", "-dotsize", "-dotty", "-eci", "-fg", "-format",
"-gssep", "-height", "-init", "-mode", "-notext", "-primary", "-gssep", "-height", "-init", "-mode", "-nobackground", "-notext",
"-rotate", "-rows", "-scale", "-secure", "-smalltext", "-square", "-primary", "-rotate", "-rows", "-scale", "-secure", "-smalltext",
"-to", "-vers", "-whitesp", "-fullmultibyte", "-separator", NULL}; "-square", "-to", "-vers", "-whitesp", "-fullmultibyte",
"-separator", NULL};
enum iOption { enum iOption {
iAddonGap, iBarcode, iBG, iBind, iBold, iBorder, iBox, iCols, iAddonGap, iBarcode, iBG, iBind, iBold, iBorder, iBox, iCols,
iDMRE, iDotSize, iDotty, iECI, iFG, iFormat, iGSSep, iHeight, iDMRE, iDotSize, iDotty, iECI, iFG, iFormat, iGSSep, iHeight,
iInit, iMode, iNoText, iPrimary, iRotate, iRows, iInit, iMode, iNoBackground, iNoText, iPrimary, iRotate, iRows,
iScale, iSecure, iSmallText, iSquare, iTo, iVers, iScale, iSecure, iSmallText, iSquare, iTo, iVers,
iWhiteSp, iFullMultiByte, iSeparator iWhiteSp, iFullMultiByte, iSeparator
}; };
@ -656,6 +665,7 @@ static int Encode(Tcl_Interp *interp, int objc,
case iDotty: case iDotty:
case iGSSep: case iGSSep:
case iInit: case iInit:
case iNoBackground:
case iNoText: case iNoText:
case iSmallText: case iSmallText:
case iSquare: case iSquare:
@ -671,9 +681,9 @@ static int Encode(Tcl_Interp *interp, int objc,
case iBG: case iBG:
/* >> Colors */ /* >> Colors */
pStr = Tcl_GetStringFromObj(objv[optionPos+1],&lStr); pStr = Tcl_GetStringFromObj(objv[optionPos+1],&lStr);
if (lStr != 6) { if (lStr != 6 && lStr != 8) {
Tcl_SetObjResult(interp, Tcl_SetObjResult(interp,
Tcl_NewStringObj("Color is not 6 hex",-1)); Tcl_NewStringObj("Color is not 6 or 8 hex",-1));
fError = 1; fError = 1;
} }
break; break;
@ -803,12 +813,17 @@ static int Encode(Tcl_Interp *interp, int objc,
} }
break; break;
case iFG: case iFG:
strncpy(hSymbol->fgcolour, pStr, 6); strncpy(hSymbol->fgcolour, pStr, lStr);
hSymbol->fgcolour[6]='\0'; hSymbol->fgcolour[lStr]='\0';
break; break;
case iBG: case iBG:
strncpy(hSymbol->bgcolour, pStr, 6); strncpy(hSymbol->bgcolour, pStr, lStr);
hSymbol->bgcolour[6]='\0'; hSymbol->bgcolour[lStr]='\0';
break;
case iNoBackground:
if (intValue) {
strcpy(hSymbol->bgcolour, "ffffff00");
}
break; break;
case iNoText: case iNoText:
hSymbol->show_hrt = (intValue?0:1); hSymbol->show_hrt = (intValue?0:1);
@ -1058,6 +1073,8 @@ static int Encode(Tcl_Interp *interp, int objc,
fError = 1; fError = 1;
} else { } else {
Tk_PhotoImageBlock sImageBlock; Tk_PhotoImageBlock sImageBlock;
char * pImageRGBA = NULL;
if (hSymbol->alphamap == NULL) {
sImageBlock.pixelPtr = (unsigned char *) hSymbol->bitmap; sImageBlock.pixelPtr = (unsigned char *) hSymbol->bitmap;
sImageBlock.width = hSymbol->bitmap_width; sImageBlock.width = hSymbol->bitmap_width;
sImageBlock.height = hSymbol->bitmap_height; sImageBlock.height = hSymbol->bitmap_height;
@ -1067,6 +1084,26 @@ static int Encode(Tcl_Interp *interp, int objc,
sImageBlock.offset[1] = 1; sImageBlock.offset[1] = 1;
sImageBlock.offset[2] = 2; sImageBlock.offset[2] = 2;
sImageBlock.offset[3] = 0; sImageBlock.offset[3] = 0;
} else {
int index;
/* Alpha channel present - prepare the image data in rgba order */
pImageRGBA = ckalloc(hSymbol->bitmap_width*hSymbol->bitmap_height*4);
for (index = 0; index < hSymbol->bitmap_width*hSymbol->bitmap_height; index++) {
pImageRGBA[index*4] = hSymbol->bitmap[index*3];
pImageRGBA[index*4+1] = hSymbol->bitmap[index*3+1];
pImageRGBA[index*4+2] = hSymbol->bitmap[index*3+2];
pImageRGBA[index*4+3] = hSymbol->alphamap[index];
}
sImageBlock.pixelPtr = (unsigned char *) pImageRGBA;
sImageBlock.width = hSymbol->bitmap_width;
sImageBlock.height = hSymbol->bitmap_height;
sImageBlock.pitch = 4*hSymbol->bitmap_width;
sImageBlock.pixelSize = 4;
sImageBlock.offset[0] = 0;
sImageBlock.offset[1] = 1;
sImageBlock.offset[2] = 2;
sImageBlock.offset[3] = 3;
}
if (0 == destWidth) { if (0 == destWidth) {
destWidth = hSymbol->bitmap_width; destWidth = hSymbol->bitmap_width;
} }
@ -1079,6 +1116,9 @@ static int Encode(Tcl_Interp *interp, int objc,
{ {
fError = 1; fError = 1;
} }
if (pImageRGBA != NULL) {
ckfree(pImageRGBA);
}
} }
} }
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/

View File

@ -2,28 +2,29 @@ Harald Oehlmann
2017-03-29 2017-03-29
How to build qzint.exe using: How to build qzint.exe using:
- QT 5.7 installed in C:\qt\Qt5.7.1 - QT 5.15.0 source package
32 bit (use the offline installer and the 32 bit package)
- MS Visual Studio 2015 (VC12) - MS Visual Studio 2015 (VC12)
Build static Qt: Build static Qt:
--------------- ---------------
- Download: qt-opensource-windows-x86-msvc2015-5.7.1.exe - Go to: https://www.qt.io/offline-installers
- Klick option "source" and deselect all other special modules. - Download the zip "Qt 5.15.x source packages" (nearly 1 GB):
- Install to C:\qt\5.7.1 (or another folder, then change the folders in the following) http://download.qt.io/official_releases/qt/5.15/5.15.0/single/qt-everywhere-src-5.15.0.zip
- Install Python (ActivePython-2.7.13.2713-win64-x64-401787.exe) - Unzip to C:\qt resulting in having the source in c:\qt\qt-everywhere-src-5.15.0
- Install Python (ActivePython-3.7.4.0000-win64-x64-e0b99d60.msi) and make it available within the path.
- Start the VS2015 x86 native console by the start menu entry: - Start the VS2015 x86 native console by the start menu entry:
Visual Studio 2015\Visual Studio Tools\Windows Desktop Command Prompts\VS2015 x86 Native Tools-Eingabeaufforderung Visual Studio 2015\Visual Studio Tools\Windows Desktop Command Prompts\VS2015 x86 Native Tools-Eingabeaufforderung
- cd C:\Qt\5.7.1\5.7\Src - cd C:\qt\qt-everywhere-src-5.15.0
- set QMAKESPEC=win32-msvc2015 - configure.bat -static -release -prefix c:\qt\5.15.0static -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -opengl desktop -no-openssl -opensource -confirm-license -make libs -nomake tools -nomake examples -nomake tests -mp
- configure.bat -static -release -prefix c:\qt\5.7.1static -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -opengl desktop -qt-sql-sqlite -no-openssl -opensource -confirm-license -make libs -nomake tools -nomake examples -nomake tests -mp
One may set another destination folder after the -prefix option. One may set another destination folder after the -prefix option.
Attention, the upper command is one long line. Attention, the upper command is one long line.
- nmake - nmake
- nmake install - nmake install
The last 3 commands run around 3 hours The last 3 commands run around 3 hours.
Make sure, that python may be found in the path.
- the huge source folder may be deleted to save around 6GB of space.
Zint Folder structure: Zint Folder structure:
---------------------- ----------------------
@ -44,9 +45,9 @@ Build targets "Release Library" for zlib and libpng.
Build zint: Build zint:
----------- -----------
- Start in the start menu: "VS2015 x86 Native Tools-Eingabeaufforderung" - Start in the start menu: "VS2015 x86 Native Tools-Eingabeaufforderung"
- set QTDIR=C:\Qt\5.7.1static - set QTDIR=C:\Qt\5.15.0static
- set PATH=C:\Qt\5.7.1static\bin;%PATH% - set PATH=C:\Qt\5.15.0static\bin;%PATH%
- set QMAKESPEC=win32-msvc2015 - set QMAKESPEC=win32-msvc
- cd $ZH - cd $ZH
- cd backend_qt - cd backend_qt
- qmake backend_qt.pro - qmake backend_qt.pro
@ -58,3 +59,13 @@ Build zint:
- nmake clean - nmake clean
- nmake release - nmake release
-> qzint.exe is in the release folder -> qzint.exe is in the release folder
Note:
For me, qt5core.lib was not found in the last step.
I only found the solution to add:
QMAKE_LIBDIR += C:/qt/5.15.0static/lib
into frontend_qt.pro
There is for sure a better solution.