1
0
mirror of https://git.code.sf.net/p/zint/code synced 2025-12-18 10:27:09 +00:00

- zint_symbol->fgcolour & bgcolour buffer lengths extended 10

-> 16 to allow for "C,M,Y,K" comma-separated decimal percentage
  strings
- API/CLI/GUI: allow foreground/background colours to be specified
  as comma-separated decimal "C,M,Y,K" strings where "C", "M" etc.
  are percentages (0-100) (ticket #281, 3rd point)
- output.c: new funcs `out_colour_get_rgb()` & `out_colour_get_cmyk()`
  and use in bmp/emf/gif etc.
- PCX: add alpha support
- GUI: fix fg/gbcolor icon background not being reset on zap
- GUI: Rearrange some Appearance tab inputs (Border Type <-> Width,
  Show Text <-> Font, Text/Font <-> Printing Scale/Size) to flow
  more naturally (hopefully)
- GUI: save button "Save As..." -> "Save..." and add icon
- CLI: add --bgcolor/colour & --fgcolor/colour synonyms
This commit is contained in:
gitlost
2023-01-29 19:51:11 +00:00
parent 48eaa0cc4e
commit ab2abccdb6
55 changed files with 1439 additions and 886 deletions

View File

@@ -330,14 +330,16 @@ Printing Scale" dialog - see [4.9 Adjusting Image Size] for further details.
![Adjusting the Print Size](images/gui_set_printing_scale.png)
The foreground and background colours can be set either using the text boxes
which accept RRGGBBAA hexadecimal values or by clicking the foreground eye
![eye](images/gui_black_eye.png) and background eye
![eye](images/gui_white_eye.png) buttons which invoke a colour picker.
which accept `"RRGGBBAA"` hexadecimal values and `"C,M,Y,K"` decimal percentage
values, or by clicking the foreground eye ![eye](images/gui_black_eye.png) and
background eye ![eye](images/gui_white_eye.png) buttons which invoke a colour
picker.
![The colour picker tool](images/gui_colour.png)
(Note that to change the colours visually, the luminence slider, the long narrow
column on the right, must be adjusted.)
column on the right, must be adjusted.) The color picker only deals in RGB(A),
and will overwrite any CMYK values with RGB(A) values once `"OK"` is selected.
Back in the Appearance tab, the colours can be reset to black-on-white using the
`"Reset"` button, and exchanged one for the other using the swap
@@ -924,8 +926,10 @@ but white-on-black is allowed by the Aztec Code, Data Matrix, DotCode, Han Xin
Code, Grid Matrix and QR Code symbology specifications.
For more specific needs the foreground (ink) and background (paper) colours can
be specified using the `--fg` and `--bg` options followed by a number in RRGGBB
hexadecimal notation (the same system used in HTML). For example the command
be specified using the `--fg` and `--bg` options followed by a number in
`"RRGGBB"` hexadecimal notation (the same system used in HTML) or in `"C,M,Y,K"`
decimal percentages format (the latter normally used with the `--cmyk` option -
see below). For example the command
```bash
zint --fg=00FF00 -d "This Text"
@@ -935,9 +939,10 @@ alters the symbol to a bright green.
![`zint -d "This Text" --fg=00FF00`](images/code128_green.svg)
Zint also supports RGBA colour information for some output file formats which
support alpha channels (currently only PNG, SVG and TIF) in a RRGGBBAA format.
For example:
Zint also supports RGBA colour information for those output file formats which
support alpha channels (currently only GIF, PCX, PNG, SVG and TIF, with GIF
supporting either a background or foreground alpha but not both) in a
`"RRGGBBAA"` format. For example:
```bash
zint --fg=00ff0055 -d "This Text"
@@ -946,8 +951,9 @@ zint --fg=00ff0055 -d "This Text"
![`zint -d "This Text" --fg=00FF0055`](images/code128_green_alpha.svg)
will produce a semi-transparent green foreground with standard (white)
background. Note that transparency is handled differently for raster and
vector files so that...
background. Note that transparency is treated differently by raster and vector
(SVG) output formats, as for vector output the background will "shine through"
a transparent foreground. For instance
```bash
zint --bg=ff0000 --fg=ffffff00 ...
@@ -955,8 +961,18 @@ zint --bg=ff0000 --fg=ffffff00 ...
will give different results for PNG and SVG. Experimentation is advised!
In addition the `--nobackground` option will simply remove the background from
EMF, EPS, GIF, PNG, SVG and TIF files.
In addition the `--nobackground` option will remove the background from all
output formats except BMP.[^4]
The `--cmyk` option is specific to output in Encapsulated PostScript (EPS) and
TIF, and selects the CMYK colour space. Custom colours should then usually be
given in the comma-separated `"C,M,Y,K"` format, where `C`, `M`, `Y` and `K` are
expressed as decimal percentage values from 0 to 100. RGB values may still be
used, in which case they will be converted formulaically to CMYK approximations.
[^4]: The background is omitted for vector outputs EMF, EPS and SVG when
`--nobackground` is given. For raster outputs GIF, PCX, PNG and TIF, the
background's alpha channel is set to zero (fully transparent).
## 4.8 Rotating the Symbol
@@ -1091,7 +1107,7 @@ Grid Matrix GB 2312 (includes ASCII) N/A
Han Xin Latin-1 GB 18030 (includes ASCII)
MaxiCode Latin-1 None
MicroPDF417 Latin-1 None
Micro QR Code Latin-1 Shift JIS (includes ASCII[^4])
Micro QR Code Latin-1 Shift JIS (includes ASCII[^5])
PDF417 Latin-1 None
QR Code Latin-1 Shift JIS (see above)
rMQR Latin-1 Shift JIS (see above)
@@ -1101,7 +1117,7 @@ All others ASCII N/A
Table: {#tbl:default_character_sets tag=": Default Character Sets"}
[^4]: Shift JIS (JIS X 0201 Roman) re-maps two ASCII characters: backslash (`\`)
[^5]: Shift JIS (JIS X 0201 Roman) re-maps two ASCII characters: backslash (`\`)
to the yen sign (¥), and tilde (`~`) to overline (U+203E).
If Zint encounters characters which can not be encoded using the default
@@ -1196,12 +1212,12 @@ ECI Code Character Encoding Scheme (ISO/IEC 8859 schemes include ASCII)
33 UTF-16LE (Low order byte first)
34 UTF-32BE (High order bytes first)
35 UTF-32LE (Low order bytes first)
170 ISO/IEC 646 Invariant[^5]
170 ISO/IEC 646 Invariant[^6]
899 8-bit binary data
Table: {#tbl:eci_codes tag=": ECI Codes"}
[^5]: ISO/IEC 646 Invariant is a subset of ASCII with 12 characters undefined:
[^6]: ISO/IEC 646 Invariant is a subset of ASCII with 12 characters undefined:
`#`, `$`, `@`, `[`, `\`, `]`, `^`, `` ` ``, `{`, `|`, `}`, `~`.
An ECI value of 0 does not encode any ECI information in the code symbol (unless
@@ -1480,10 +1496,6 @@ Zint can output a representation of the symbol data as a set of hexadecimal
values if asked to output to a text file (`"*.txt"`) or if given the option
`--filetype=txt`. This can be used for test and diagnostic purposes.
The `--cmyk` option is specific to output in Encapsulated PostScript and TIF,
and converts the RGB colours used to the CMYK colour space. Setting custom
colours at the command line will still need to be done in RRGGBB format.
Additional options are available which are specific to certain symbologies.
These may, for example, control the amount of error correction data or the
size of the symbol. These options are discussed in section [6. Types of
@@ -1700,7 +1712,7 @@ struct zint_vector_string *string;
struct zint_vector_circle *circle;
prepare_canvas(my_symbol->vector->width, my_symbol->vector->height,
my_symbol->scale, my_symbol->fgcolour, my_symbol->bgcolor,
my_symbol->scale, my_symbol->fgcolour, my_symbol->bgcolour,
rotate_angle);
for (rect = my_symbol->vector->rectangles; rect; rect = rect->next) {
@@ -1739,7 +1751,7 @@ Variable Name Type Meaning Default Value
`height` float Symbol height, excluding Symbol dependent
fixed width-to-height
symbols.[^6]
symbols.[^7]
`scale` float Scale factor for adjusting 1.0
size of image.
@@ -1757,15 +1769,17 @@ Variable Name Type Meaning Default Value
`fgcolour` character Foreground (ink) `"000000"`
string colour as RGB/RGBA
hexadecimal string. Must be
6 or 8 characters followed
by a terminating `NUL`.
hexadecimal string or
`"C,M,Y,K"` decimal
percentages string, with a
terminating `NUL`.
`bgcolour` character Background (paper) `"ffffff"`
string colour as RGB/RGBA
hexadecimal string. Must be
6 or 8 characters followed
by a terminating `NUL`.
hexadecimal string or
`"C,M,Y,K"` decimal
percentages string, with a
terminating `NUL`.
`fgcolor` pointer Points to fgcolour allowing
alternate spelling.
@@ -1869,7 +1883,7 @@ Variable Name Type Meaning Default Value
Table: API Structure `zint_symbol` {#tbl:api_structure_zint_symbol tag="$ $"}
[^6]: The `height` value is ignored for Aztec (including HIBC and Aztec Rune),
[^7]: The `height` value is ignored for Aztec (including HIBC and Aztec Rune),
Code One, Data Matrix (including HIBC), DotCode, Grid Matrix, Han Xin, MaxiCode,
QR Code (including HIBC, Micro QR, rMQR and UPNQR), and Ultracode - all of which
have a fixed width-to-height ratio (or, in the case of Code One, a fixed
@@ -1894,12 +1908,11 @@ int main(int argc, char **argv)
}
```
Background removal for EMF, EPS, GIF, PNG, SVG and TIF files can be achieved by
setting the background alpha to `"00"` where the values for R, G and B will be
ignored:
Background removal for all outputs except BMP can be achieved by setting the
background alpha to `"00"` where the values for R, G and B will be ignored:
```c
strcpy(my_symbol->bgcolour, "55555500");
strcpy(my_symbol->bgcolour, "55555500");
```
## 5.7 Handling Errors
@@ -1998,7 +2011,7 @@ int main(int argc, char **argv)
This code will exit with the appropriate message:
```
Error 653: Malformed foreground colour 'NONSENSE' (hexadecimal only)
Error 691: Malformed foreground RGB colour 'nonsense' (hexadecimal only)
```
To treat all warnings as errors, set `symbol->warn_level` to `WARN_FAIL_ALL`.
@@ -2033,10 +2046,10 @@ Value Effect
------------------------- -----------------------------------------------------
0 No options selected.
`BARCODE_BIND_TOP` Boundary bar above the symbol only.[^7]
`BARCODE_BIND_TOP` Boundary bar above the symbol only.[^8]
`BARCODE_BIND` Boundary bars above and below the symbol and between
rows if stacking multiple symbols.[^8]
rows if stacking multiple symbols.[^9]
`BARCODE_BOX` Add a box surrounding the symbol and whitespace.
@@ -2061,7 +2074,7 @@ Value Effect
separate colour channels (`OUT_BUFFER` only).
`BARCODE_QUIET_ZONES` Add compliant quiet zones (additional to any
specified whitespace).[^9]
specified whitespace).[^10]
`BARCODE_NO_QUIET_ZONES` Disable quiet zones, notably those with defaults.
@@ -2071,13 +2084,13 @@ Value Effect
Table: API `output_options` Values {#tbl:api_output_options tag="$ $"}
[^7]: The `BARCODE_BIND_TOP` flag is set by default for DPD - see [6.1.10.7 DPD
[^8]: The `BARCODE_BIND_TOP` flag is set by default for DPD - see [6.1.10.7 DPD
Code].
[^8]: The `BARCODE_BIND` flag is always set for Codablock-F, Code 16K and Code
[^9]: The `BARCODE_BIND` flag is always set for Codablock-F, Code 16K and Code
49. Special considerations apply to ITF-14 - see [6.1.2.6 ITF-14].
[^9]: Codablock-F, Code 16K, Code 49, EAN-2 to EAN-13, ISBN, ITF-14, UPC-A and
[^10]: Codablock-F, Code 16K, Code 49, EAN-2 to EAN-13, ISBN, ITF-14, UPC-A and
UPC-E have compliant quiet zones added by default.
\clearpage
@@ -2831,13 +2844,13 @@ Alphabet No. 1 (ISO/IEC 8859-1)].
![`zint -b CODE128AB -d "130170X178"`](images/code128ab.svg)
It is sometimes advantageous to stop Code 128 from using Code Set C which
compresses numerical data. The `BARCODE_CODE128AB`[^10] variant (symbology 60)
compresses numerical data. The `BARCODE_CODE128AB`[^11] variant (symbology 60)
suppresses Code Set C in favour of Code Sets A and B.
Note that the special escapes to manually switch Code Sets mentioned above are
not available for this variant (nor for any other).
[^10]: `BARCODE_CODE128AB` previously used the name `BARCODE_CODE128B`, which is
[^11]: `BARCODE_CODE128AB` previously used the name `BARCODE_CODE128B`, which is
still recognised.
#### 6.1.10.3 GS1-128