From 674687feba3b81d5cd6616b3f32b370db1fdd4a0 Mon Sep 17 00:00:00 2001 From: Harald Oehlmann Date: Fri, 14 Oct 2016 16:23:15 +0200 Subject: [PATCH] tcl backend 2.5.2: Include the upstream reverted image format --- backend_tcl/zint.c | 47 +++++++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/backend_tcl/zint.c b/backend_tcl/zint.c index be2e2721..30477f95 100644 --- a/backend_tcl/zint.c +++ b/backend_tcl/zint.c @@ -32,10 +32,12 @@ History 2014-06-16 2.5.0 HaO - First implementation - 2016-09-14 2.5.1 HaO -- Added Codablock F options "-rows". + First implementation + 2016-09-14 2.5.1 HaO +- Added Codablock F options "-rows". - Adopted to new image format of zint + 2016-10-14 2.5.2 HaO +- Include the upstream reverted image format */ #if defined(__WIN32__) || defined(_WIN32) || defined(WIN32) @@ -75,7 +77,7 @@ /*----------------------------------------------------------------------------*/ /* > File option defines */ -#define VERSION "2.5.1" +#define VERSION "2.5.2" /*----------------------------------------------------------------------------*/ /* >>>>> Hepler defines */ @@ -180,8 +182,8 @@ static char *s_code_list[] = { "RSSExpandedStacked-CC", "Channel", "CodeOne", - "GridMatrix", - "DotCode", + "GridMatrix", + "DotCode", "HanXin", NULL}; @@ -269,8 +271,8 @@ static int s_code_number[] = { BARCODE_RSS_EXPSTACK_CC, BARCODE_CHANNEL, BARCODE_CODEONE, - BARCODE_GRIDMATRIX, - BARCODE_DOTCODE, + BARCODE_GRIDMATRIX, + BARCODE_DOTCODE, BARCODE_HANXIN, 0}; @@ -293,7 +295,7 @@ static char help_message[] = "zint tcl(stub,obj) dll\n" " -fg color: set foreground color as 6 hex rrggbb\n" " -bg color: set background color as 6 hex rrggbb\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, QR-Code, Plessy\n" " -rotate angle: Image rotation by 0,90 or 270 degrees\n" " -secure integer: EC Level (PDF417, QR)\n" @@ -516,7 +518,7 @@ static int Encode(Tcl_Interp *interp, int objc, break; case iBorder: case iHeight: - case iCols: + case iCols: case iRows: case iVers: case iSecure: @@ -638,12 +640,12 @@ static int Encode(Tcl_Interp *interp, int objc, } break; case iSecure: - case iMode: + case iMode: case iRows: /* >> Int in Option 1 */ if ( (optionIndex==iSecure && (intValue < 1 || intValue > 8)) || (optionIndex==iMode && (intValue < 0 || intValue > 6)) - || (optionIndex==iRows && (intValue < 0 || intValue > 44))) + || (optionIndex==iRows && (intValue < 0 || intValue > 44))) { Tcl_SetObjResult(interp, Tcl_NewStringObj("secure/mode/rows out of range", -1)); @@ -783,23 +785,12 @@ static int Encode(Tcl_Interp *interp, int objc, Tcl_SetObjResult(interp, Tcl_NewStringObj("Unknown photo image", -1)); fError = 1; - } else { - int pitch; - Tk_PhotoImageBlock sImageBlock; - /* The format is: - * RGBRGB..., pad to multiple of 4 bytes - * Y Axis inverted. - * So the pitch is negative and filled to 4 bytes - * The origin pointer is the last row start - */ - pitch = 3 * hSymbol->bitmap_width; - if ( pitch % 4 != 0) - pitch += 4 - (pitch % 4); - sImageBlock.pixelPtr = (unsigned char *) (hSymbol->bitmap - + pitch * (hSymbol->bitmap_height - 1) ); + } else { + Tk_PhotoImageBlock sImageBlock; + sImageBlock.pixelPtr = (unsigned char *) hSymbol->bitmap; sImageBlock.width = hSymbol->bitmap_width; - sImageBlock.height = hSymbol->bitmap_height; - sImageBlock.pitch = pitch * -1; + sImageBlock.height = hSymbol->bitmap_height; + sImageBlock.pitch = 3*hSymbol->bitmap_width; sImageBlock.pixelSize = 3; sImageBlock.offset[0] = 0; sImageBlock.offset[1] = 1;