libansilove

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

commit 8761d27d94d7043c10d61fada4c374190ea6edcd
parent 52151c4bc8020f23c1191040751ab7e4cac1779c
Author: Frederic Cambus <fred@statdns.com>
Date:   Fri, 25 Sep 2020 21:07:24 +0200

Introduce canvas_width/canvas_height variables and refactor canvas creation.

Diffstat:
Msrc/loaders/ansi.c | 10++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/loaders/ansi.c b/src/loaders/ansi.c @@ -458,11 +458,13 @@ ansilove_ansi(struct ansilove_ctx *ctx, struct ansilove_options *options) if (options->diz) columns = fmin(columnMax, options->columns); + uint32_t canvas_width = columns * options->bits; + uint32_t canvas_height = rowMax * fontData.height; + /* create that damn thingy */ - if (!options->truecolor) - canvas = gdImageCreate(columns * options->bits, rowMax * fontData.height); - else - canvas = gdImageCreateTrueColor(columns * options->bits, rowMax * fontData.height); + canvas = options->truecolor ? + gdImageCreateTrueColor(canvas_width, canvas_height) : + gdImageCreate(canvas_width, canvas_height); if (!canvas) { ctx->error = ANSILOVE_GD_ERROR;