Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for PNG without alpha channel #187

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion qrenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ static int rle = 0;
static int svg_path = 0;
static int micro = 0;
static int inline_svg = 0;
static int png_no_alpha = 0;
static int strict_versioning = 0;
static QRecLevel level = QR_ECLEVEL_L;
static QRencodeMode hint = QR_MODE_8;
Expand Down Expand Up @@ -93,6 +94,7 @@ static const struct option options[] = {
{"svg-path" , no_argument , &svg_path, 1},
{"inline" , no_argument , &inline_svg, 1},
{"strict-version", no_argument , &strict_versioning, 1},
{"png-no-alpha" , no_argument , &png_no_alpha, 1},
{"foreground" , required_argument, NULL, 'f'},
{"background" , required_argument, NULL, 'b'},
{"version" , no_argument , NULL, 'V'},
Expand Down Expand Up @@ -155,6 +157,8 @@ static void usage(int help, int longopt, int status)
" specify foreground/background color in hexadecimal notation.\n"
" 6-digit (RGB) or 8-digit (RGBA) form are supported.\n"
" Color output support available only in PNG, EPS and SVG.\n\n"
" --png-no-alpha\n"
" do not add alpha channel in PNG output.\n\n"
" --strict-version\n"
" disable automatic version number adjustment. If the input data is\n"
" too large for the specified version, the program exits with the\n"
Expand Down Expand Up @@ -359,7 +363,8 @@ static int writePNG(const QRcode *qrcode, const char *outfile, enum imageType ty
alpha_values[0] = fg_color[3];
alpha_values[1] = bg_color[3];
png_set_PLTE(png_ptr, info_ptr, palette, 2);
png_set_tRNS(png_ptr, info_ptr, alpha_values, 2, NULL);
if (!png_no_alpha)
png_set_tRNS(png_ptr, info_ptr, alpha_values, 2, NULL);
}

png_init_io(png_ptr, fp);
Expand Down
3 changes: 3 additions & 0 deletions qrencode.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ specify foreground/background color in hexadecimal notation.
6-digit (RGB) or 8-digit (RGBA) form are supported.
Color output support available only in PNG, EPS and SVG.
.TP
.B \-\-png-no-alpha
do not add alpha channel in PNG output.
.TP
.B \-\-strict\-version
disable automatic version number adjustment. If the input data is
too large for the specified version, the program exits with the
Expand Down