libansilove

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

commit 6be11834084b631b7af607a45143545d0514a754
parent 0da23ea28d322b0267a3885ae398cb55960cb74c
Author: Frederic Cambus <fred@statdns.com>
Date:   Fri, 25 Sep 2020 21:13:54 +0200

Introduce and use canvas_width/canvas_height variables for canvas creation in the Binary loader.

Diffstat:
Msrc/loaders/binary.c | 7+++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/loaders/binary.c b/src/loaders/binary.c @@ -45,9 +45,12 @@ ansilove_binary(struct ansilove_ctx *ctx, struct ansilove_options *options) /* Default to 160 columns if columns option wasn't set */ options->columns = options->columns ? options->columns : 160; + uint32_t canvas_width, canvas_height; + canvas_width = options->columns * options->bits; + canvas_height = (ctx->length / 2) / options->columns * fontData.height; + /* allocate buffer image memory */ - canvas = gdImageCreate(options->columns * options->bits, - (ctx->length / 2) / options->columns * fontData.height); + canvas = gdImageCreate(canvas_width, canvas_height); if (!canvas) { ctx->error = ANSILOVE_GD_ERROR;