ansilove

ANSI and ASCII art to PNG converter in C
Log | Files | Refs | README | LICENSE

commit 7e3a77603882554d0dd55191e3413d5600daf60c
parent 7ce883dee0100b7ce827a09db7bafb26a5b5bd26
Author: Frederic Cambus <fred@statdns.com>
Date:   Sat, 15 Apr 2017 21:49:42 +0200

Rename some variables

Diffstat:
Msrc/ansilove.c | 8++++----
Msrc/ansilove.h | 2+-
Msrc/loaders/ansi.c | 28++++++++++++++--------------
Msrc/loaders/ansi.h | 4++--
Msrc/loaders/artworx.c | 8++++----
Msrc/loaders/binary.c | 12++++++------
Msrc/loaders/icedraw.c | 8++++----
Msrc/loaders/pcboard.c | 16++++++++--------
Msrc/loaders/pcboard.h | 4++--
Msrc/loaders/tundra.c | 12++++++------
Msrc/loaders/xbin.c | 14+++++++-------
11 files changed, 58 insertions(+), 58 deletions(-)

diff --git a/src/ansilove.c b/src/ansilove.c @@ -14,22 +14,22 @@ // shared method for drawing characters void alDrawChar(gdImagePtr im, const unsigned char *font_data, int32_t bits, int32_t font_size_y, int32_t position_x, int32_t position_y, - int32_t color_background, int32_t color_foreground, unsigned char character) + int32_t background, int32_t foreground, unsigned char character) { int32_t column, line; gdImageFilledRectangle(im, position_x * bits, position_y*font_size_y, position_x * bits + - bits - 1, position_y * font_size_y + font_size_y - 1, color_background); + bits - 1, position_y * font_size_y + font_size_y - 1, background); for (line = 0; line < font_size_y; line++) { for (column = 0; column < bits; column++) { if ((font_data[line+character*font_size_y] & (0x80 >> column)) != 0) { - gdImageSetPixel(im, position_x * bits + column, position_y*font_size_y + line, color_foreground); + gdImageSetPixel(im, position_x * bits + column, position_y*font_size_y + line, foreground); if (bits==9 && column==7 && character > 191 && character < 224) { - gdImageSetPixel(im, position_x * bits + 8, position_y * font_size_y + line, color_foreground); + gdImageSetPixel(im, position_x * bits + 8, position_y * font_size_y + line, foreground); } } } diff --git a/src/ansilove.h b/src/ansilove.h @@ -31,6 +31,6 @@ // prototypes void alDrawChar(gdImagePtr im, const unsigned char *font_data, int32_t bits, int32_t font_size_y, int32_t position_x, int32_t position_y, - int32_t color_background, int32_t color_foreground, unsigned char character); + int32_t background, int32_t foreground, unsigned char character); #endif diff --git a/src/loaders/ansi.c b/src/loaders/ansi.c @@ -59,7 +59,7 @@ void ansi(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, c unsigned char ansi_sequence_character; // default color values - int32_t color_background = 0, color_foreground = 7; + int32_t background = 0, foreground = 7; // text attributes bool bold = false, underline = false, italics = false, blink = false; @@ -292,8 +292,8 @@ void ansi(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, c if (seqValue == 0) { - color_background = 0; - color_foreground = 7; + background = 0; + foreground = 7; bold = false; underline = false; italics = false; @@ -304,7 +304,7 @@ void ansi(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, c { if (!workbench) { - color_foreground+=8; + foreground+=8; } bold = true; } @@ -323,28 +323,28 @@ void ansi(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, c { if (!workbench) { - color_background+=8; + background+=8; } blink = true; } if (seqValue > 29 && seqValue < 38) { - color_foreground = seqValue - 30; + foreground = seqValue - 30; if (bold) { - color_foreground+=8; + foreground+=8; } } if (seqValue > 39 && seqValue < 48) { - color_background = seqValue - 40; + background = seqValue - 40; if (blink && icecolors) { - color_background+=8; + background+=8; } } } @@ -388,8 +388,8 @@ void ansi(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, c temp = realloc(ansi_buffer, (structIndex + 1) * sizeof(struct ansiChar)); ansi_buffer = temp; - ansi_buffer[structIndex].color_background = color_background; - ansi_buffer[structIndex].color_foreground = color_foreground; + ansi_buffer[structIndex].background = background; + ansi_buffer[structIndex].foreground = foreground; ansi_buffer[structIndex].current_character = current_character; ansi_buffer[structIndex].bold = bold; ansi_buffer[structIndex].italics = italics; @@ -485,8 +485,8 @@ void ansi(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, c for (loop = 0; loop < ansiBufferItems; loop++) { // grab ANSi char from our structure array - color_background = ansi_buffer[loop].color_background; - color_foreground = ansi_buffer[loop].color_foreground; + background = ansi_buffer[loop].background; + foreground = ansi_buffer[loop].foreground; character = ansi_buffer[loop].current_character; bold = ansi_buffer[loop].bold; italics = ansi_buffer[loop].italics; @@ -499,7 +499,7 @@ void ansi(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, c position_x, position_y, ced_background, ced_foreground, character); } else { alDrawChar(im_ANSi, fontData.font_data, bits, fontData.font_size_y, - position_x, position_y, colors[color_background], colors[color_foreground], character); + position_x, position_y, colors[background], colors[foreground], character); } } diff --git a/src/loaders/ansi.h b/src/loaders/ansi.h @@ -18,8 +18,8 @@ struct ansiChar { int32_t position_x; int32_t position_y; - int32_t color_background; - int32_t color_foreground; + int32_t background; + int32_t foreground; int32_t current_character; bool bold; bool italics; diff --git a/src/loaders/artworx.c b/src/loaders/artworx.c @@ -55,7 +55,7 @@ void artworx(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output // process ADF int32_t position_x = 0, position_y = 0; - int32_t character, attribute, color_foreground, color_background; + int32_t character, attribute, foreground, background; loop = 192 + 4096 + 1; while(loop < inputFileSize) @@ -69,10 +69,10 @@ void artworx(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output character = inputFileBuffer[loop]; attribute = inputFileBuffer[loop+1]; - color_background = (attribute & 240) >> 4; - color_foreground = attribute & 15; + background = (attribute & 240) >> 4; + foreground = attribute & 15; - alDrawChar(im_ADF, font_data, 8, 16, position_x, position_y, color_background, color_foreground, character); + alDrawChar(im_ADF, font_data, 8, 16, position_x, position_y, background, foreground, character); position_x++; loop+=2; diff --git a/src/loaders/binary.c b/src/loaders/binary.c @@ -54,7 +54,7 @@ void binary(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, colors[15] = gdImageColorAllocate(im_Binary, 255, 255, 255); // process binary - int32_t character, attribute, color_background, color_foreground; + int32_t character, attribute, background, foreground; int32_t loop = 0, position_x = 0, position_y = 0; while (loop < inputFileSize) @@ -68,16 +68,16 @@ void binary(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, character = inputFileBuffer[loop]; attribute = inputFileBuffer[loop+1]; - color_background = (attribute & 240) >> 4; - color_foreground = (attribute & 15); + background = (attribute & 240) >> 4; + foreground = (attribute & 15); - if (color_background > 8 && !icecolors) + if (background > 8 && !icecolors) { - color_background -= 8; + background -= 8; } alDrawChar(im_Binary, fontData.font_data, bits, fontData.font_size_y, - position_x, position_y, colors[color_background], colors[color_foreground], character); + position_x, position_y, colors[background], colors[foreground], character); position_x++; loop+=2; diff --git a/src/loaders/icedraw.c b/src/loaders/icedraw.c @@ -111,7 +111,7 @@ void icedraw(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output // render IDF int32_t position_x = 0, position_y = 0; - int32_t character, attribute, color_foreground, color_background; + int32_t character, attribute, foreground, background; for (loop = 0; loop < i ; loop +=2) { @@ -124,10 +124,10 @@ void icedraw(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output character = idf_buffer[loop]; attribute = idf_buffer[loop+1]; - color_background = (attribute & 240) >> 4; - color_foreground = attribute & 15; + background = (attribute & 240) >> 4; + foreground = attribute & 15; - alDrawChar(im_IDF, font_data, 8, 16, position_x, position_y, colors[color_background], colors[color_foreground], character); + alDrawChar(im_IDF, font_data, 8, 16, position_x, position_y, colors[background], colors[foreground], character); position_x++; } diff --git a/src/loaders/pcboard.c b/src/loaders/pcboard.c @@ -26,7 +26,7 @@ void pcboard(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output // process PCBoard int32_t character, current_character, next_character; - int32_t color_background = 0, color_foreground = 7; + int32_t background = 0, foreground = 7; int32_t position_x = 0, position_y = 0, position_x_max = 0, position_y_max = 0; // PCB buffer structure array definition @@ -80,8 +80,8 @@ void pcboard(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output if (current_character == 64 && next_character == 88) { // set graphics rendition - color_background = inputFileBuffer[loop+2]; - color_foreground = inputFileBuffer[loop+3]; + background = inputFileBuffer[loop+2]; + foreground = inputFileBuffer[loop+3]; loop+=3; } else if (current_character == 64 && next_character == 67 && @@ -131,8 +131,8 @@ void pcboard(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output // write current character in pcbChar structure pcboard_buffer[structIndex].position_x = position_x; pcboard_buffer[structIndex].position_y = position_y; - pcboard_buffer[structIndex].color_background = color_background; - pcboard_buffer[structIndex].color_foreground = color_foreground; + pcboard_buffer[structIndex].background = background; + pcboard_buffer[structIndex].foreground = foreground; pcboard_buffer[structIndex].current_character = current_character; position_x++; @@ -179,12 +179,12 @@ void pcboard(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output // grab our chars out of the structure position_x = pcboard_buffer[loop].position_x; position_y = pcboard_buffer[loop].position_y; - color_background = pcboard_buffer[loop].color_background; - color_foreground = pcboard_buffer[loop].color_foreground; + background = pcboard_buffer[loop].background; + foreground = pcboard_buffer[loop].foreground; character = pcboard_buffer[loop].current_character; alDrawChar(im_PCB, fontData.font_data, bits, fontData.font_size_y, - position_x, position_y, colors[color_background], colors[color_foreground], character); + position_x, position_y, colors[background], colors[foreground], character); } // create output image diff --git a/src/loaders/pcboard.h b/src/loaders/pcboard.h @@ -18,8 +18,8 @@ struct pcbChar { int32_t position_x; int32_t position_y; - int32_t color_background; - int32_t color_foreground; + int32_t background; + int32_t foreground; int32_t current_character; }; diff --git a/src/loaders/tundra.c b/src/loaders/tundra.c @@ -36,7 +36,7 @@ void tundra(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, } // read tundra file a first time to find the image size - int32_t character, color_background = 0, color_foreground = 0; + int32_t character, background = 0, foreground = 0; int32_t loop = 0, position_x = 0, position_y = 0; loop=9; @@ -132,7 +132,7 @@ void tundra(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, if (character == 2) { - color_foreground = + foreground = (inputFileBuffer[loop + 3] << 16) + (inputFileBuffer[loop + 4] << 8) + inputFileBuffer[loop + 5]; @@ -143,7 +143,7 @@ void tundra(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, if (character == 4) { - color_background = (inputFileBuffer[loop + 3] << 16) + (inputFileBuffer[loop + 4] << 8) + + background = (inputFileBuffer[loop + 3] << 16) + (inputFileBuffer[loop + 4] << 8) + inputFileBuffer[loop+5]; character = inputFileBuffer[loop+1]; @@ -153,11 +153,11 @@ void tundra(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, if (character==6) { - color_foreground = + foreground = (inputFileBuffer[loop + 3] << 16) + (inputFileBuffer[loop + 4] << 8) + inputFileBuffer[loop+5]; - color_background = + background = (inputFileBuffer[loop + 7] << 16) + (inputFileBuffer[loop + 8] << 8) + inputFileBuffer[loop+9]; @@ -169,7 +169,7 @@ void tundra(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, if (character !=1 && character !=2 && character !=4 && character !=6) { alDrawChar(im_Tundra, fontData.font_data, bits, fontData.font_size_y, - position_x, position_y, color_background, color_foreground, character); + position_x, position_y, background, foreground, character); position_x++; } diff --git a/src/loaders/xbin.c b/src/loaders/xbin.c @@ -95,7 +95,7 @@ void xbin(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, c } int32_t position_x = 0, position_y = 0; - int32_t character, attribute, color_foreground, color_background; + int32_t character, attribute, foreground, background; // read compressed xbin if( (xbin_flags & 4) == 4) { @@ -145,10 +145,10 @@ void xbin(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, c } } - color_background = (attribute & 240) >> 4; - color_foreground = attribute & 15; + background = (attribute & 240) >> 4; + foreground = attribute & 15; - alDrawChar(im_XBIN, font_data, 8, 16, position_x, position_y, colors[color_background], colors[color_foreground], character); + alDrawChar(im_XBIN, font_data, 8, 16, position_x, position_y, colors[background], colors[foreground], character); position_x++; @@ -173,10 +173,10 @@ void xbin(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, c character = inputFileBuffer[offset]; attribute = inputFileBuffer[offset+1]; - color_background = (attribute & 240) >> 4; - color_foreground = attribute & 15; + background = (attribute & 240) >> 4; + foreground = attribute & 15; - alDrawChar(im_XBIN, font_data, 8, xbin_fontsize, position_x, position_y, colors[color_background], colors[color_foreground], character); + alDrawChar(im_XBIN, font_data, 8, xbin_fontsize, position_x, position_y, colors[background], colors[foreground], character); position_x++; offset+=2;