Add alpha channel support and --nobackground option

Alpha channel for PNG and SVG and option to remove background from EMF
This commit is contained in:
Robin Stuart 2020-08-02 22:26:39 +01:00
parent 18e3b41e0f
commit 47cac63e7f
9 changed files with 195 additions and 72 deletions

View file

@ -1,6 +1,7 @@
*******************************************************************************
* For reference the following is a text-only version of the Zint manual. *
* The full version can be accessed at http://zint.org.uk/Manual.aspx *
* The HTML version can be accessed at http://zint.org.uk/Manual.aspx *
* however this text file is more likely to be up-to-date. *
*******************************************************************************
Zint Barcode Generator and Zint Barcode Studio User Manual
@ -402,6 +403,24 @@ zint --fg=004700 -d "This"
alters the symbol to a dark green.
Zint also supports RGBA colour information for some output file formats which
support alpha channels (currently only PNG and SVG) in a RRGGBBAA format.
For example:
zint --fg=00ff0055 -d "This"
will produce a semi-transparent green foreground with standard (white)
background. Note that transparency is handled differently for raster and
vector files so that...
zint --bg=ff0000 --fg=ffffff00 ...
will give different results for PNG and SVG. Experimentation is advised!
Also note that these options don't work properly with Maxicode yet.
In addition the --nobackground option will simply remove the background from
PNG, SVG and EMF files.
4.8 Rotating the Symbol
-----------------------
The symbol can be rotated through four orientations using the --rotate= option
@ -827,15 +846,19 @@ output_options | integer | Set various output file | 0 (none)
| | parameters (see section |
| | 5.8). |
fgcolour | character | Foreground (ink) colour as | "000000"
| string | RGB hexadecimal string. |
| | Must be 6 characters |
| | followed by terminating |
| | \0 character. |
| string | RGB/RGBA hexadecimal |
| | string. Must be 6 or 8 |
| | characters followed by |
| | terminating \0. |
fgcolor | pointer | Points to fgcolour allowing |
| | alternate spelling. |
bgcolour | character | Background (paper) colour | "ffffff"
| string | as RGB hexadecimal |
| | string. Must be 6 chara- |
| | ters followed by termin- |
| | ating \0 character. |
| string | as RGB/RGBA hexadecimal |
| | string. Must be 6 or 8 |
| | characters followed by |
| | terminating \0. |
bgcolor | pointer | Points to bgcolour allowing |
| | alternate spelling. |
outfile | character | Contains the name of the | "out.png"
| string | file to output a result- |
| | ing barcode symbol to. |
@ -903,6 +926,11 @@ int main(int argc, char **argv)
return 0;
}
Background removal for PNG, SVG and EMF files can be achieved by setting the
background alpha to "00" where the values for R, G and B will be ignored:
strcpy(my_symbol->bgcolour, "55555500");
5.6 Handling Errors
-------------------
If errors occur during encoding an integer value is passed back to the calling