libansilove

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

commit 04843712e0a5765a76fb666220762b17fc9f3409
parent 1e7a7d41b4b80cc46b2be3f8a5800e6e1657917c
Author: Josh Renaud <josh@joshrenaud.com>
Date:   Fri, 28 Sep 2018 11:51:22 -0500

Fix height calculation in tundra.c, add support for user-specified columns

Diffstat:
Msrc/loaders/tundra.c | 13++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/loaders/tundra.c b/src/loaders/tundra.c @@ -24,6 +24,9 @@ int ansilove_tundra(struct ansilove_ctx *ctx, struct ansilove_options *options) struct fontStruct fontData; char tundra_version; + options->columns = options->columns ? options->columns : 80; + uint32_t columns = options->columns; + // font selection alSelectFont(&fontData, options->font); @@ -44,7 +47,7 @@ int ansilove_tundra(struct ansilove_ctx *ctx, struct ansilove_options *options) uint32_t loop = 9, column = 0, row = 1; while (loop < ctx->length) { - if (column == 80) { + if (column == columns) { column = 0; row++; } @@ -78,13 +81,17 @@ int ansilove_tundra(struct ansilove_ctx *ctx, struct ansilove_options *options) loop += 9; column++; break; + + default: + column++; } loop++; } + // allocate buffer image memory - canvas = gdImageCreateTrueColor(80 * options->bits, (row) * fontData.height); + canvas = gdImageCreateTrueColor(columns * options->bits, (row) * fontData.height); if (!canvas) { ctx->error = GD_ERROR; @@ -98,7 +105,7 @@ int ansilove_tundra(struct ansilove_ctx *ctx, struct ansilove_options *options) loop = 9; while (loop < ctx->length) { - if (column == 80) { + if (column == columns) { column = 0; row++; }