mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
png: ULTRA: allow for fgcolour if bind/box, bug introduced by [ed3cc5] (MR #111)
This commit is contained in:
parent
0337548c77
commit
dfb9345b75
@ -1083,11 +1083,11 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
|
|||||||
|
|
||||||
if (symbol->debug & ZINT_DEBUG_PRINT) {
|
if (symbol->debug & ZINT_DEBUG_PRINT) {
|
||||||
printf("ZBarcode_Encode: symbology: %d, input_mode: 0x%X, ECI: %d, option_1: %d, option_2: %d,"
|
printf("ZBarcode_Encode: symbology: %d, input_mode: 0x%X, ECI: %d, option_1: %d, option_2: %d,"
|
||||||
" option_3: %d, scale: %g\n output_options: 0x%X, in_length: %d,"
|
" option_3: %d, scale: %g\n output_options: 0x%X, fg: %s, bg: %s,"
|
||||||
" First 10 source: \"%.10s\", First 10 primary: \"%.10s\"\n",
|
" in_length: %d, First 10 source: \"%.10s\", First 10 primary: \"%.10s\"\n",
|
||||||
symbol->symbology, symbol->input_mode, symbol->eci, symbol->option_1, symbol->option_2,
|
symbol->symbology, symbol->input_mode, symbol->eci, symbol->option_1, symbol->option_2,
|
||||||
symbol->option_3, symbol->scale, symbol->output_options, in_length,
|
symbol->option_3, symbol->scale, symbol->output_options, symbol->fgcolour, symbol->bgcolour,
|
||||||
source, symbol->primary);
|
in_length, source, symbol->primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
warn_number = 0;
|
warn_number = 0;
|
||||||
|
@ -163,10 +163,22 @@ INTERNAL int png_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
|
|||||||
num_trans = 8;
|
num_trans = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* For Ultracode, have foreground only if have bind/box */
|
||||||
|
if (symbol->border_width > 0 && (symbol->output_options & (BARCODE_BIND | BARCODE_BOX))) {
|
||||||
|
/* Check whether can re-use black */
|
||||||
|
if (fg.red == 0 && fg.green == 0 && fg.blue == 0) {
|
||||||
|
map['1'] = 7; /* Re-use black */
|
||||||
|
} else {
|
||||||
|
map['1'] = num_palette;
|
||||||
|
palette[num_palette++] = fg;
|
||||||
|
if (fg_alpha != 0xff) {
|
||||||
|
trans_alpha[num_trans++] = fg_alpha;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* For Ultracode, have background only if have whitespace/quiet zones */
|
/* For Ultracode, have background only if have whitespace/quiet zones */
|
||||||
if (pixelbuf[0] == '0' || pixelbuf[symbol->bitmap_width - 1] == '0'
|
if (symbol->whitespace_width > 0 || symbol->whitespace_height > 0) { /* TODO: BARCODE_QUIET_ZONES also */
|
||||||
|| pixelbuf[symbol->bitmap_height * (symbol->bitmap_width - 1)] == '0'
|
|
||||||
|| pixelbuf[symbol->bitmap_height * symbol->bitmap_width - 1] == '0') {
|
|
||||||
/* Check whether can re-use white */
|
/* Check whether can re-use white */
|
||||||
if (bg.red == 0xff && bg.green == 0xff && bg.blue == 0xff && bg_alpha == fg_alpha) {
|
if (bg.red == 0xff && bg.green == 0xff && bg.blue == 0xff && bg_alpha == fg_alpha) {
|
||||||
map['0'] = 0; /* Re-use white */
|
map['0'] = 0; /* Re-use white */
|
||||||
|
BIN
backend/tests/data/png/ultra_fgalpha_hvwsp1_box1.png
Normal file
BIN
backend/tests/data/png/ultra_fgalpha_hvwsp1_box1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 248 B |
@ -175,15 +175,16 @@ static void test_print(int index, int generate, int debug) {
|
|||||||
/* 38*/ { BARCODE_ULTRA, -1, -1, -1, 2, -1, -1, -1, -1, 0, 0, "", "FF000033", "12345", "", "../data/png/ultra_bgalpha.png", "" },
|
/* 38*/ { BARCODE_ULTRA, -1, -1, -1, 2, -1, -1, -1, -1, 0, 0, "", "FF000033", "12345", "", "../data/png/ultra_bgalpha.png", "" },
|
||||||
/* 39*/ { BARCODE_ULTRA, -1, -1, -1, 2, -1, -1, -1, -1, 0, 0, "0000007F", "FF0000", "12345", "", "../data/png/ultra_fgalpha.png", "" },
|
/* 39*/ { BARCODE_ULTRA, -1, -1, -1, 2, -1, -1, -1, -1, 0, 0, "0000007F", "FF0000", "12345", "", "../data/png/ultra_fgalpha.png", "" },
|
||||||
/* 40*/ { BARCODE_ULTRA, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "0000007F", "", "12345", "", "../data/png/ultra_fgalpha_nobg.png", "" },
|
/* 40*/ { BARCODE_ULTRA, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "0000007F", "", "12345", "", "../data/png/ultra_fgalpha_nobg.png", "" },
|
||||||
/* 41*/ { BARCODE_ULTRA, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0.5f, "", "", "1", "", "../data/png/ultra_odd.png", "" },
|
/* 41*/ { BARCODE_ULTRA, -1, 1, BARCODE_BOX, 1, 1, -1, -1, -1, 0, 0, "00FF007F", "BABDB6", "12345", "", "../data/png/ultra_fgalpha_hvwsp1_box1.png", "" },
|
||||||
/* 42*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0.5f, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "../data/png/maxicode_0.5.png", "6 dpmm, 150 dpi" },
|
/* 42*/ { BARCODE_ULTRA, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0.5f, "", "", "1", "", "../data/png/ultra_odd.png", "" },
|
||||||
/* 43*/ { BARCODE_MAXICODE, -1, 1, BARCODE_BOX, 3, -1, -1, -1, -1, 0, 0.7f, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "../data/png/maxicode_0.7_wsp3_box1.png", "8 dpmm, 200 dpi" },
|
/* 43*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0.5f, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "../data/png/maxicode_0.5.png", "6 dpmm, 150 dpi" },
|
||||||
/* 44*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1.4f, "1111117F", "EEEEEEEE", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "../data/png/maxicode_1.4_bgfgalpha.png", "16 dpmm, 400 dpi" },
|
/* 44*/ { BARCODE_MAXICODE, -1, 1, BARCODE_BOX, 3, -1, -1, -1, -1, 0, 0.7f, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "../data/png/maxicode_0.7_wsp3_box1.png", "8 dpmm, 200 dpi" },
|
||||||
/* 45*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, -1, 0, 2.1f, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "../data/png/maxicode_2.1.png", "24 dpmm, 600 dpi" },
|
/* 45*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1.4f, "1111117F", "EEEEEEEE", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "../data/png/maxicode_1.4_bgfgalpha.png", "16 dpmm, 400 dpi" },
|
||||||
/* 46*/ { BARCODE_MAXICODE, -1, 2, BARCODE_BOX, 1, 1, -1, -1, -1, 0, 0, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "../data/png/maxicode_hvwsp1_box2.png", "" },
|
/* 46*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, -1, 0, 2.1f, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "../data/png/maxicode_2.1.png", "24 dpmm, 600 dpi" },
|
||||||
/* 47*/ { BARCODE_MAXICODE, -1, 1, BARCODE_BIND, -1, 1, -1, -1, -1, 0, 0, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "../data/png/maxicode_vwsp1_bind1.png", "" },
|
/* 47*/ { BARCODE_MAXICODE, -1, 2, BARCODE_BOX, 1, 1, -1, -1, -1, 0, 0, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "../data/png/maxicode_hvwsp1_box2.png", "" },
|
||||||
/* 48*/ { BARCODE_DATAMATRIX, -1, 1, BARCODE_BIND | BARCODE_DOTTY_MODE, -1, -1, -1, -1, -1, 0, 2.0f, "", "", "1234", "", "../data/png/datamatrix_2.0_bind1_dotty.png", "" },
|
/* 48*/ { BARCODE_MAXICODE, -1, 1, BARCODE_BIND, -1, 1, -1, -1, -1, 0, 0, "", "", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "", "../data/png/maxicode_vwsp1_bind1.png", "" },
|
||||||
/* 49*/ { BARCODE_DATAMATRIX, -1, 1, BARCODE_BIND | BARCODE_DOTTY_MODE, 1, 1, -1, -1, -1, 0, 2.0f, "", "", "1234", "", "../data/png/datamatrix_2.0_hvwsp1_bind1_dotty.png", "" },
|
/* 49*/ { BARCODE_DATAMATRIX, -1, 1, BARCODE_BIND | BARCODE_DOTTY_MODE, -1, -1, -1, -1, -1, 0, 2.0f, "", "", "1234", "", "../data/png/datamatrix_2.0_bind1_dotty.png", "" },
|
||||||
|
/* 50*/ { BARCODE_DATAMATRIX, -1, 1, BARCODE_BIND | BARCODE_DOTTY_MODE, 1, 1, -1, -1, -1, 0, 2.0f, "", "", "1234", "", "../data/png/datamatrix_2.0_hvwsp1_bind1_dotty.png", "" },
|
||||||
};
|
};
|
||||||
int data_size = ARRAY_SIZE(data);
|
int data_size = ARRAY_SIZE(data);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user