- 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
are shown by a blank.
- 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
----------

View File

@ -113,6 +113,11 @@ INTERNAL int ps_plot(struct zint_symbol *symbol) {
int colour_index, colour_rect_counter;
char ps_color[30];
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 ((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) {
feps = stdout;
} else {

View File

@ -132,6 +132,7 @@ INTERNAL int svg_plot(struct zint_symbol *symbol) {
struct zint_vector_string *string;
char colour_code[7];
int html_len;
#ifdef _MSC_VER
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]);
}
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++) {
switch(symbol->text[i]) {

View File

@ -20,6 +20,9 @@
#include <stdio.h>
#include <math.h>
#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 {
static const char* fontstyle = "Arial";
@ -84,13 +87,8 @@ namespace Zint {
}
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));
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));
}

View File

@ -52,7 +52,7 @@ proc Generate {} {
::zintimg blank
::zintimg configure -width 0 -height 0
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
- RSSExpandedStacked-CC -> GS1DataBarExpandedStacked-CC
*** 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)
@ -216,6 +221,7 @@ static char *s_code_list[] = {
"GS1DataBarSstackedOmni",
"GS1DataBarExpandedStacked",
"Planet",
"DPDCode",
"MicroPDF417",
"USPSIntelligentMail",
"Plessey",
@ -313,6 +319,7 @@ static int s_code_number[] = {
BARCODE_DBAR_OMNSTK,
BARCODE_DBAR_EXPSTK,
BARCODE_PLANET,
BARCODE_DPD,
BARCODE_MICROPDF417,
BARCODE_USPS_IMAIL,
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"
" -height integer: Symbol height in modules\n"
" -whitesp integer: horizontal quiet zone in modules\n"
" -fg color: set foreground color as 6 hex rrggbb\n"
" -bg color: set background 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 or 8 hex rrggbbaa\n"
" -nobackground bool: set background transparent\n"
" -cols integer: PDF417, Codablock F: number of columns\n"
" -rows integer: Codablock F: number of rows\n"
" -vers integer: Symbology option\n"
@ -624,13 +632,14 @@ static int Encode(Tcl_Interp *interp, int objc,
char *optionList[] = {
"-addongap", "-barcode", "-bg", "-bind", "-bold", "-border", "-box",
"-cols", "-dmre", "-dotsize", "-dotty", "-eci", "-fg", "-format",
"-gssep", "-height", "-init", "-mode", "-notext", "-primary",
"-rotate", "-rows", "-scale", "-secure", "-smalltext", "-square",
"-to", "-vers", "-whitesp", "-fullmultibyte", "-separator", NULL};
"-gssep", "-height", "-init", "-mode", "-nobackground", "-notext",
"-primary", "-rotate", "-rows", "-scale", "-secure", "-smalltext",
"-square", "-to", "-vers", "-whitesp", "-fullmultibyte",
"-separator", NULL};
enum iOption {
iAddonGap, iBarcode, iBG, iBind, iBold, iBorder, iBox, iCols,
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,
iWhiteSp, iFullMultiByte, iSeparator
};
@ -656,6 +665,7 @@ static int Encode(Tcl_Interp *interp, int objc,
case iDotty:
case iGSSep:
case iInit:
case iNoBackground:
case iNoText:
case iSmallText:
case iSquare:
@ -671,9 +681,9 @@ static int Encode(Tcl_Interp *interp, int objc,
case iBG:
/* >> Colors */
pStr = Tcl_GetStringFromObj(objv[optionPos+1],&lStr);
if (lStr != 6) {
if (lStr != 6 && lStr != 8) {
Tcl_SetObjResult(interp,
Tcl_NewStringObj("Color is not 6 hex",-1));
Tcl_NewStringObj("Color is not 6 or 8 hex",-1));
fError = 1;
}
break;
@ -803,12 +813,17 @@ static int Encode(Tcl_Interp *interp, int objc,
}
break;
case iFG:
strncpy(hSymbol->fgcolour, pStr, 6);
hSymbol->fgcolour[6]='\0';
strncpy(hSymbol->fgcolour, pStr, lStr);
hSymbol->fgcolour[lStr]='\0';
break;
case iBG:
strncpy(hSymbol->bgcolour, pStr, 6);
hSymbol->bgcolour[6]='\0';
strncpy(hSymbol->bgcolour, pStr, lStr);
hSymbol->bgcolour[lStr]='\0';
break;
case iNoBackground:
if (intValue) {
strcpy(hSymbol->bgcolour, "ffffff00");
}
break;
case iNoText:
hSymbol->show_hrt = (intValue?0:1);
@ -1058,6 +1073,8 @@ static int Encode(Tcl_Interp *interp, int objc,
fError = 1;
} else {
Tk_PhotoImageBlock sImageBlock;
char * pImageRGBA = NULL;
if (hSymbol->alphamap == NULL) {
sImageBlock.pixelPtr = (unsigned char *) hSymbol->bitmap;
sImageBlock.width = hSymbol->bitmap_width;
sImageBlock.height = hSymbol->bitmap_height;
@ -1067,6 +1084,26 @@ static int Encode(Tcl_Interp *interp, int objc,
sImageBlock.offset[1] = 1;
sImageBlock.offset[2] = 2;
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) {
destWidth = hSymbol->bitmap_width;
}
@ -1079,6 +1116,9 @@ static int Encode(Tcl_Interp *interp, int objc,
{
fError = 1;
}
if (pImageRGBA != NULL) {
ckfree(pImageRGBA);
}
}
}
/*------------------------------------------------------------------------*/

View File

@ -2,28 +2,29 @@ Harald Oehlmann
2017-03-29
How to build qzint.exe using:
- QT 5.7 installed in C:\qt\Qt5.7.1
32 bit (use the offline installer and the 32 bit package)
- QT 5.15.0 source package
- MS Visual Studio 2015 (VC12)
Build static Qt:
---------------
- Download: qt-opensource-windows-x86-msvc2015-5.7.1.exe
- Klick option "source" and deselect all other special modules.
- Install to C:\qt\5.7.1 (or another folder, then change the folders in the following)
- Install Python (ActivePython-2.7.13.2713-win64-x64-401787.exe)
- Go to: https://www.qt.io/offline-installers
- Download the zip "Qt 5.15.x source packages" (nearly 1 GB):
http://download.qt.io/official_releases/qt/5.15/5.15.0/single/qt-everywhere-src-5.15.0.zip
- 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:
Visual Studio 2015\Visual Studio Tools\Windows Desktop Command Prompts\VS2015 x86 Native Tools-Eingabeaufforderung
- cd C:\Qt\5.7.1\5.7\Src
- set QMAKESPEC=win32-msvc2015
- 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
- cd C:\qt\qt-everywhere-src-5.15.0
- 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
One may set another destination folder after the -prefix option.
Attention, the upper command is one long line.
- nmake
- 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:
----------------------
@ -44,9 +45,9 @@ Build targets "Release Library" for zlib and libpng.
Build zint:
-----------
- Start in the start menu: "VS2015 x86 Native Tools-Eingabeaufforderung"
- set QTDIR=C:\Qt\5.7.1static
- set PATH=C:\Qt\5.7.1static\bin;%PATH%
- set QMAKESPEC=win32-msvc2015
- set QTDIR=C:\Qt\5.15.0static
- set PATH=C:\Qt\5.15.0static\bin;%PATH%
- set QMAKESPEC=win32-msvc
- cd $ZH
- cd backend_qt
- qmake backend_qt.pro
@ -58,3 +59,13 @@ Build zint:
- nmake clean
- nmake release
-> 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.