libansilove

Library for converting ANSI, ASCII, and other formats to PNG
Log | Files | Refs | README | LICENSE

commit 64265edcfb64086b1aded9063ae3c9ed93a73a04
parent 59da172c3a0e2735024f0cd2531870ad23cc6dda
Author: Frederic Cambus <fred@statdns.com>
Date:   Thu,  3 Oct 2019 22:23:13 +0200

Move background transparency operations in the output function.

Diffstat:
Msrc/loaders/ansi.c | 8--------
Msrc/output.c | 3+++
2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/src/loaders/ansi.c b/src/loaders/ansi.c @@ -67,7 +67,6 @@ ansilove_ansi(struct ansilove_ctx *ctx, struct ansilove_options *options) int16_t columns = options->columns; bool ced = false; - bool transparent = false; bool workbench = false; const char *errstr; @@ -79,9 +78,6 @@ ansilove_ansi(struct ansilove_ctx *ctx, struct ansilove_options *options) case ANSILOVE_MODE_CED: ced = true; break; - case ANSILOVE_MODE_TRANSPARENT: - transparent = true; - break; case ANSILOVE_MODE_WORKBENCH: workbench = true; break; @@ -530,10 +526,6 @@ ansilove_ansi(struct ansilove_ctx *ctx, struct ansilove_options *options) } - /* transparent flag used? */ - if (transparent) - gdImageColorTransparent(canvas, 0); - /* create output image */ if (output(ctx, options, canvas) != 0) { free(ansi_buffer); diff --git a/src/output.c b/src/output.c @@ -23,6 +23,9 @@ output(struct ansilove_ctx *ctx, struct ansilove_options *options, /* XXX Allow combining DOS aspect ratio and Retina */ if (!options->scale_factor && !options->dos) { + if (options->mode == ANSILOVE_MODE_TRANSPARENT) + gdImageColorTransparent(im_Source, 0); + ctx->png.buffer = gdImagePngPtr(im_Source, &ctx->png.length); gdImageDestroy(im_Source); } else if (options->dos) {