libansilove

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

commit 4f4a1dabf6b652bd3fddcb6b7c38eeaf16d94b78
parent 6b4077b84c4c667a5b753cd63e8778f23eaf7c7b
Author: Frederic Cambus <fred@statdns.com>
Date:   Wed,  4 Jul 2018 11:10:20 +0200

Rename the output struct to ansilove_options, and its consumers as well

Diffstat:
Minclude/ansilove.h | 16++++++++--------
Msrc/loaders/ansi.c | 22+++++++++++-----------
Msrc/loaders/artworx.c | 4++--
Msrc/loaders/binary.c | 16++++++++--------
Msrc/loaders/icedraw.c | 4++--
Msrc/loaders/pcboard.c | 10+++++-----
Msrc/loaders/tundra.c | 10+++++-----
Msrc/loaders/xbin.c | 4++--
8 files changed, 43 insertions(+), 43 deletions(-)

diff --git a/include/ansilove.h b/include/ansilove.h @@ -27,7 +27,7 @@ struct ansilove_ctx { int error; }; -struct output { +struct ansilove_options { char *fileName; char *retina; char *font; @@ -39,12 +39,12 @@ struct output { uint32_t retinaScaleFactor; }; -int ansilove_ansi(struct ansilove_ctx *, struct output *); -int ansilove_artworx(struct ansilove_ctx *, struct output *); -int ansilove_binary(struct ansilove_ctx *, struct output *); -int ansilove_icedraw(struct ansilove_ctx *, struct output *); -int ansilove_pcboard(struct ansilove_ctx *, struct output *); -int ansilove_tundra(struct ansilove_ctx *, struct output *); -int ansilove_xbin(struct ansilove_ctx *, struct output *); +int ansilove_ansi(struct ansilove_ctx *, struct ansilove_options *); +int ansilove_artworx(struct ansilove_ctx *, struct ansilove_options *); +int ansilove_binary(struct ansilove_ctx *, struct ansilove_options *); +int ansilove_icedraw(struct ansilove_ctx *, struct ansilove_options *); +int ansilove_pcboard(struct ansilove_ctx *, struct ansilove_options *); +int ansilove_tundra(struct ansilove_ctx *, struct ansilove_options *); +int ansilove_xbin(struct ansilove_ctx *, struct ansilove_options *); #endif diff --git a/src/loaders/ansi.c b/src/loaders/ansi.c @@ -25,7 +25,7 @@ struct ansiChar { bool underline; }; -int ansilove_ansi(struct ansilove_ctx *ctx, struct output *outputFile) +int ansilove_ansi(struct ansilove_ctx *ctx, struct ansilove_options *options) { // ladies and gentlemen, it's type declaration time struct fontStruct fontData; @@ -39,14 +39,14 @@ int ansilove_ansi(struct ansilove_ctx *ctx, struct output *outputFile) const char *errstr; // font selection - alSelectFont(&fontData, outputFile->font); + alSelectFont(&fontData, options->font); // to deal with the bits flag, we declared handy bool types - if (!strcmp(outputFile->mode, "ced")) { + if (!strcmp(options->mode, "ced")) { ced = true; - } else if (!strcmp(outputFile->mode, "transparent")) { + } else if (!strcmp(options->mode, "transparent")) { transparent = true; - } else if (!strcmp(outputFile->mode, "workbench")) { + } else if (!strcmp(options->mode, "workbench")) { workbench = true; } @@ -305,7 +305,7 @@ int ansilove_ansi(struct ansilove_ctx *ctx, struct output *outputFile) { background = seqValue - 40; - if (blink && outputFile->icecolors) + if (blink && options->icecolors) background += 8; } @@ -379,11 +379,11 @@ int ansilove_ansi(struct ansilove_ctx *ctx, struct output *outputFile) if (ced) columns = 78; - if (outputFile->diz) + if (options->diz) columns = fmin(columnMax, 80); // create that damn thingy - canvas = gdImageCreate(columns * outputFile->bits, (rowMax)*fontData.height); + canvas = gdImageCreate(columns * options->bits, (rowMax)*fontData.height); if (!canvas) { ctx->error = GD_ERROR; @@ -432,10 +432,10 @@ int ansilove_ansi(struct ansilove_ctx *ctx, struct output *outputFile) row = ansi_buffer[loop].row; if (ced) { - drawchar(canvas, fontData.font_data, outputFile->bits, fontData.height, + drawchar(canvas, fontData.font_data, options->bits, fontData.height, column, row, ced_background, ced_foreground, character); } else { - drawchar(canvas, fontData.font_data, outputFile->bits, fontData.height, + drawchar(canvas, fontData.font_data, options->bits, fontData.height, column, row, colors[background], colors[foreground], character); } @@ -446,7 +446,7 @@ int ansilove_ansi(struct ansilove_ctx *ctx, struct output *outputFile) gdImageColorTransparent(canvas, 0); // create output image - output(canvas, outputFile->fileName, outputFile->retina, outputFile->retinaScaleFactor); + output(canvas, options->fileName, options->retina, options->retinaScaleFactor); // free memory free(ansi_buffer); diff --git a/src/loaders/artworx.c b/src/loaders/artworx.c @@ -11,7 +11,7 @@ #include "../ansilove.h" -int ansilove_artworx(struct ansilove_ctx *ctx, struct output *outputFile) +int ansilove_artworx(struct ansilove_ctx *ctx, struct ansilove_options *options) { // libgd image pointers gdImagePtr canvas; @@ -65,7 +65,7 @@ int ansilove_artworx(struct ansilove_ctx *ctx, struct output *outputFile) } // create output file - output(canvas, outputFile->fileName, outputFile->retina, outputFile->retinaScaleFactor); + output(canvas, options->fileName, options->retina, options->retinaScaleFactor); return 0; } diff --git a/src/loaders/binary.c b/src/loaders/binary.c @@ -11,7 +11,7 @@ #include "../ansilove.h" -int ansilove_binary(struct ansilove_ctx *ctx, struct output *outputFile) +int ansilove_binary(struct ansilove_ctx *ctx, struct ansilove_options *options) { // binary files must have an even size if (ctx->length % 2) { @@ -23,14 +23,14 @@ int ansilove_binary(struct ansilove_ctx *ctx, struct output *outputFile) struct fontStruct fontData; // font selection - alSelectFont(&fontData, outputFile->font); + alSelectFont(&fontData, options->font); // libgd image pointers gdImagePtr canvas; // allocate buffer image memory - canvas = gdImageCreate(outputFile->columns * outputFile->bits, - ((ctx->length / 2) / outputFile->columns * fontData.height)); + canvas = gdImageCreate(options->columns * options->bits, + ((ctx->length / 2) / options->columns * fontData.height)); if (!canvas) { ctx->error = GD_ERROR; @@ -54,7 +54,7 @@ int ansilove_binary(struct ansilove_ctx *ctx, struct output *outputFile) uint32_t loop = 0, column = 0, row = 0; while (loop < ctx->length) { - if (column == outputFile->columns) { + if (column == options->columns) { column = 0; row++; } @@ -65,10 +65,10 @@ int ansilove_binary(struct ansilove_ctx *ctx, struct output *outputFile) background = (attribute & 240) >> 4; foreground = (attribute & 15); - if (background > 8 && !outputFile->icecolors) + if (background > 8 && !options->icecolors) background -= 8; - drawchar(canvas, fontData.font_data, outputFile->bits, fontData.height, + drawchar(canvas, fontData.font_data, options->bits, fontData.height, column, row, colors[background], colors[foreground], character); column++; @@ -76,7 +76,7 @@ int ansilove_binary(struct ansilove_ctx *ctx, struct output *outputFile) } // create output image - output(canvas, outputFile->fileName, outputFile->retina, outputFile->retinaScaleFactor); + output(canvas, options->fileName, options->retina, options->retinaScaleFactor); return 0; } diff --git a/src/loaders/icedraw.c b/src/loaders/icedraw.c @@ -11,7 +11,7 @@ #include "../ansilove.h" -int ansilove_icedraw(struct ansilove_ctx *ctx, struct output *outputFile) +int ansilove_icedraw(struct ansilove_ctx *ctx, struct ansilove_options *options) { // extract relevant part of the IDF header, 16-bit endian unsigned short int32_t x2 = (ctx->buffer[9] << 8) + ctx->buffer[8]; @@ -115,7 +115,7 @@ int ansilove_icedraw(struct ansilove_ctx *ctx, struct output *outputFile) } // create output file - output(canvas, outputFile->fileName, outputFile->retina, outputFile->retinaScaleFactor); + output(canvas, options->fileName, options->retina, options->retinaScaleFactor); // free memory free(idf_buffer); diff --git a/src/loaders/pcboard.c b/src/loaders/pcboard.c @@ -20,14 +20,14 @@ struct pcbChar { int32_t current_character; }; -int ansilove_pcboard(struct ansilove_ctx *ctx, struct output *outputFile) +int ansilove_pcboard(struct ansilove_ctx *ctx, struct ansilove_options *options) { // some type declarations struct fontStruct fontData; uint32_t loop, structIndex; // font selection - alSelectFont(&fontData, outputFile->font); + alSelectFont(&fontData, options->font); // libgd image pointers gdImagePtr canvas; @@ -135,7 +135,7 @@ int ansilove_pcboard(struct ansilove_ctx *ctx, struct output *outputFile) rowMax++; // allocate buffer image memory - canvas = gdImageCreate(80 * outputFile->bits, (rowMax)*fontData.height); + canvas = gdImageCreate(80 * options->bits, (rowMax)*fontData.height); // allocate black color and create background canvas gdImageColorAllocate(canvas, 0, 0, 0); @@ -162,12 +162,12 @@ int ansilove_pcboard(struct ansilove_ctx *ctx, struct output *outputFile) foreground = pcboard_buffer[loop].foreground; character = pcboard_buffer[loop].current_character; - drawchar(canvas, fontData.font_data, outputFile->bits, fontData.height, + drawchar(canvas, fontData.font_data, options->bits, fontData.height, column, row, colors[background], colors[foreground], character); } // create output image - output(canvas, outputFile->fileName, outputFile->retina, outputFile->retinaScaleFactor); + output(canvas, options->fileName, options->retina, options->retinaScaleFactor); // free memory free(pcboard_buffer); diff --git a/src/loaders/tundra.c b/src/loaders/tundra.c @@ -18,14 +18,14 @@ #define TUNDRA_COLOR_FOREGROUND 4 #define TUNDRA_COLOR_BOTH 6 -int ansilove_tundra(struct ansilove_ctx *ctx, struct output *outputFile) +int ansilove_tundra(struct ansilove_ctx *ctx, struct ansilove_options *options) { // some type declarations struct fontStruct fontData; char tundra_version; // font selection - alSelectFont(&fontData, outputFile->font); + alSelectFont(&fontData, options->font); // libgd image pointers gdImagePtr canvas; @@ -84,7 +84,7 @@ int ansilove_tundra(struct ansilove_ctx *ctx, struct output *outputFile) } // allocate buffer image memory - canvas = gdImageCreateTrueColor(80 * outputFile->bits, (row) * fontData.height); + canvas = gdImageCreateTrueColor(80 * options->bits, (row) * fontData.height); if (!canvas) { ctx->error = GD_ERROR; @@ -153,7 +153,7 @@ int ansilove_tundra(struct ansilove_ctx *ctx, struct output *outputFile) } if (character != 1 && character != 2 && character != 4 && character != 6) { - drawchar(canvas, fontData.font_data, outputFile->bits, fontData.height, + drawchar(canvas, fontData.font_data, options->bits, fontData.height, column, row, background, foreground, character); column++; @@ -163,7 +163,7 @@ int ansilove_tundra(struct ansilove_ctx *ctx, struct output *outputFile) } // create output image - output(canvas, outputFile->fileName, outputFile->retina, outputFile->retinaScaleFactor); + output(canvas, options->fileName, options->retina, options->retinaScaleFactor); return 0; } diff --git a/src/loaders/xbin.c b/src/loaders/xbin.c @@ -11,7 +11,7 @@ #include "../ansilove.h" -int ansilove_xbin(struct ansilove_ctx *ctx, struct output *outputFile) +int ansilove_xbin(struct ansilove_ctx *ctx, struct ansilove_options *options) { const unsigned char *font_data; unsigned char *font_data_xbin = NULL; @@ -168,7 +168,7 @@ int ansilove_xbin(struct ansilove_ctx *ctx, struct output *outputFile) } // create output file - output(canvas, outputFile->fileName, outputFile->retina, outputFile->retinaScaleFactor); + output(canvas, options->fileName, options->retina, options->retinaScaleFactor); // nuke garbage free(font_data_xbin);