Skip to content

Commit

Permalink
Harmonize canvas names in all loaders
Browse files Browse the repository at this point in the history
  • Loading branch information
fcambus committed Apr 18, 2017
1 parent 2c47072 commit b9ddd74
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 131 deletions.
88 changes: 44 additions & 44 deletions src/loaders/ansi.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void ansi(unsigned char *inputFileBuffer, int32_t inputFileSize, char *outputFil
}

// libgd image pointers
gdImagePtr im_ANSi;
gdImagePtr canvas;

// ANSi processing loops
int32_t loop = 0, ansi_sequence_loop, seq_graphics_loop;
Expand Down Expand Up @@ -418,9 +418,9 @@ void ansi(unsigned char *inputFileBuffer, int32_t inputFileSize, char *outputFil
}

// create that damn thingy
im_ANSi = gdImageCreate(columns * bits,(position_y_max)*fontData.height);
canvas = gdImageCreate(columns * bits,(position_y_max)*fontData.height);

if (!im_ANSi) {
if (!canvas) {
perror("Can't allocate ANSi buffer image memory");
exit(6);
}
Expand All @@ -431,52 +431,52 @@ void ansi(unsigned char *inputFileBuffer, int32_t inputFileSize, char *outputFil

if (ced)
{
ced_background = gdImageColorAllocate(im_ANSi, 170, 170, 170);
ced_foreground = gdImageColorAllocate(im_ANSi, 0, 0, 0);
gdImageFill(im_ANSi, 0, 0, ced_background);
ced_background = gdImageColorAllocate(canvas, 170, 170, 170);
ced_foreground = gdImageColorAllocate(canvas, 0, 0, 0);
gdImageFill(canvas, 0, 0, ced_background);
}
else if (workbench)
{
gdImageFill(im_ANSi, 0, 0, 0);

colors[0] = gdImageColorAllocate(im_ANSi, 170, 170, 170);
colors[1] = gdImageColorAllocate(im_ANSi, 0, 0, 0);
colors[2] = gdImageColorAllocate(im_ANSi, 255, 255, 255);
colors[3] = gdImageColorAllocate(im_ANSi, 102, 136, 187);
colors[4] = gdImageColorAllocate(im_ANSi, 0, 0, 255);
colors[5] = gdImageColorAllocate(im_ANSi, 255, 0, 255);
colors[6] = gdImageColorAllocate(im_ANSi, 0, 255, 255);
colors[7] = gdImageColorAllocate(im_ANSi, 255, 255, 255);
colors[8] = gdImageColorAllocate(im_ANSi, 170, 170, 170);
colors[9] = gdImageColorAllocate(im_ANSi, 0, 0, 0);
colors[10] = gdImageColorAllocate(im_ANSi, 255, 255, 255);
colors[11] = gdImageColorAllocate(im_ANSi, 102, 136, 187);
colors[12] = gdImageColorAllocate(im_ANSi, 0, 0, 255);
colors[13] = gdImageColorAllocate(im_ANSi, 255, 0, 255);
colors[14] = gdImageColorAllocate(im_ANSi, 0, 255, 255);
colors[15] = gdImageColorAllocate(im_ANSi, 255, 255, 255);
gdImageFill(canvas, 0, 0, 0);

colors[0] = gdImageColorAllocate(canvas, 170, 170, 170);
colors[1] = gdImageColorAllocate(canvas, 0, 0, 0);
colors[2] = gdImageColorAllocate(canvas, 255, 255, 255);
colors[3] = gdImageColorAllocate(canvas, 102, 136, 187);
colors[4] = gdImageColorAllocate(canvas, 0, 0, 255);
colors[5] = gdImageColorAllocate(canvas, 255, 0, 255);
colors[6] = gdImageColorAllocate(canvas, 0, 255, 255);
colors[7] = gdImageColorAllocate(canvas, 255, 255, 255);
colors[8] = gdImageColorAllocate(canvas, 170, 170, 170);
colors[9] = gdImageColorAllocate(canvas, 0, 0, 0);
colors[10] = gdImageColorAllocate(canvas, 255, 255, 255);
colors[11] = gdImageColorAllocate(canvas, 102, 136, 187);
colors[12] = gdImageColorAllocate(canvas, 0, 0, 255);
colors[13] = gdImageColorAllocate(canvas, 255, 0, 255);
colors[14] = gdImageColorAllocate(canvas, 0, 255, 255);
colors[15] = gdImageColorAllocate(canvas, 255, 255, 255);
}

else
{
// Allocate standard ANSi color palette

colors[0] = gdImageColorAllocate(im_ANSi, 0, 0, 0);
colors[1] = gdImageColorAllocate(im_ANSi, 170, 0, 0);
colors[2] = gdImageColorAllocate(im_ANSi, 0, 170, 0);
colors[3] = gdImageColorAllocate(im_ANSi, 170, 85, 0);
colors[4] = gdImageColorAllocate(im_ANSi, 0, 0, 170);
colors[5] = gdImageColorAllocate(im_ANSi, 170, 0, 170);
colors[6] = gdImageColorAllocate(im_ANSi, 0, 170, 170);
colors[7] = gdImageColorAllocate(im_ANSi, 170, 170, 170);
colors[8] = gdImageColorAllocate(im_ANSi, 85, 85, 85);
colors[9] = gdImageColorAllocate(im_ANSi, 255, 85, 85);
colors[10] = gdImageColorAllocate(im_ANSi, 85, 255, 85);
colors[11] = gdImageColorAllocate(im_ANSi, 255, 255, 85);
colors[12] = gdImageColorAllocate(im_ANSi, 85, 85, 255);
colors[13] = gdImageColorAllocate(im_ANSi, 255, 85, 255);
colors[14] = gdImageColorAllocate(im_ANSi, 85, 255, 255);
colors[15] = gdImageColorAllocate(im_ANSi, 255, 255, 255);
colors[0] = gdImageColorAllocate(canvas, 0, 0, 0);
colors[1] = gdImageColorAllocate(canvas, 170, 0, 0);
colors[2] = gdImageColorAllocate(canvas, 0, 170, 0);
colors[3] = gdImageColorAllocate(canvas, 170, 85, 0);
colors[4] = gdImageColorAllocate(canvas, 0, 0, 170);
colors[5] = gdImageColorAllocate(canvas, 170, 0, 170);
colors[6] = gdImageColorAllocate(canvas, 0, 170, 170);
colors[7] = gdImageColorAllocate(canvas, 170, 170, 170);
colors[8] = gdImageColorAllocate(canvas, 85, 85, 85);
colors[9] = gdImageColorAllocate(canvas, 255, 85, 85);
colors[10] = gdImageColorAllocate(canvas, 85, 255, 85);
colors[11] = gdImageColorAllocate(canvas, 255, 255, 85);
colors[12] = gdImageColorAllocate(canvas, 85, 85, 255);
colors[13] = gdImageColorAllocate(canvas, 255, 85, 255);
colors[14] = gdImageColorAllocate(canvas, 85, 255, 255);
colors[15] = gdImageColorAllocate(canvas, 255, 255, 255);
}

// even more definitions, sigh
Expand All @@ -496,10 +496,10 @@ void ansi(unsigned char *inputFileBuffer, int32_t inputFileSize, char *outputFil
position_y = ansi_buffer[loop].position_y;

if (ced) {
alDrawChar(im_ANSi, fontData.font_data, bits, fontData.height,
alDrawChar(canvas, fontData.font_data, bits, fontData.height,
position_x, position_y, ced_background, ced_foreground, character);
} else {
alDrawChar(im_ANSi, fontData.font_data, bits, fontData.height,
alDrawChar(canvas, fontData.font_data, bits, fontData.height,
position_x, position_y, colors[background], colors[foreground], character);
}

Expand All @@ -508,11 +508,11 @@ void ansi(unsigned char *inputFileBuffer, int32_t inputFileSize, char *outputFil
// transparent flag used?
if (transparent)
{
gdImageColorTransparent(im_ANSi, 0);
gdImageColorTransparent(canvas, 0);
}

// create output image
output(im_ANSi, outputFile, retinaout, createRetinaRep);
output(canvas, outputFile, retinaout, createRetinaRep);

// free memory
free(ansi_buffer);
Expand Down
14 changes: 7 additions & 7 deletions src/loaders/artworx.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ void artworx(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output
unsigned char *font_data_adf;

// libgd image pointers
gdImagePtr im_ADF;
gdImagePtr canvas;

// create ADF instance
im_ADF = gdImageCreate(640,(((inputFileSize - 192 - 4096 -1) / 2) / 80) * 16);
canvas = gdImageCreate(640,(((inputFileSize - 192 - 4096 -1) / 2) / 80) * 16);

// error output
if (!im_ADF) {
if (!canvas) {
perror("Can't allocate buffer image memory");
exit (7);
}
Expand All @@ -48,12 +48,12 @@ void artworx(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output
for (loop = 0; loop < 16; loop++)
{
index = (adf_colors[loop] * 3) + 1;
gdImageColorAllocate(im_ADF, (inputFileBuffer[index] << 2 | inputFileBuffer[index] >> 4),
gdImageColorAllocate(canvas, (inputFileBuffer[index] << 2 | inputFileBuffer[index] >> 4),
(inputFileBuffer[index + 1] << 2 | inputFileBuffer[index + 1] >> 4),
(inputFileBuffer[index + 2] << 2 | inputFileBuffer[index + 2] >> 4));
}

gdImageColorAllocate(im_ADF, 0, 0, 0);
gdImageColorAllocate(canvas, 0, 0, 0);

// process ADF
int32_t position_x = 0, position_y = 0;
Expand All @@ -74,14 +74,14 @@ void artworx(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output
background = (attribute & 240) >> 4;
foreground = attribute & 15;

alDrawChar(im_ADF, font_data, 8, 16, position_x, position_y, background, foreground, character);
alDrawChar(canvas, font_data, 8, 16, position_x, position_y, background, foreground, character);

position_x++;
loop+=2;
}

// create output file
output(im_ADF, outputFile, retinaout, createRetinaRep);
output(canvas, outputFile, retinaout, createRetinaRep);

// nuke garbage
free(font_data_adf);
Expand Down
44 changes: 22 additions & 22 deletions src/loaders/binary.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,39 +20,39 @@ void binary(unsigned char *inputFileBuffer, int32_t inputFileSize, char *outputF
alSelectFont(&fontData, font);

// libgd image pointers
gdImagePtr im_Binary;
gdImagePtr canvas;

// allocate buffer image memory
im_Binary = gdImageCreate(columns * bits,
canvas = gdImageCreate(columns * bits,
((inputFileSize / 2) / columns * fontData.height));

if (!im_Binary) {
if (!canvas) {
perror("Error, can't allocate buffer image memory");
exit (6);
}

// allocate black color
gdImageColorAllocate(im_Binary, 0, 0, 0);
gdImageColorAllocate(canvas, 0, 0, 0);

// allocate color palette
int32_t colors[16];

colors[0] = gdImageColorAllocate(im_Binary, 0, 0, 0);
colors[1] = gdImageColorAllocate(im_Binary, 0, 0, 170);
colors[2] = gdImageColorAllocate(im_Binary, 0, 170, 0);
colors[3] = gdImageColorAllocate(im_Binary, 0, 170, 170);
colors[4] = gdImageColorAllocate(im_Binary, 170, 0, 0);
colors[5] = gdImageColorAllocate(im_Binary, 170, 0, 170);
colors[6] = gdImageColorAllocate(im_Binary, 170, 85, 0);
colors[7] = gdImageColorAllocate(im_Binary, 170, 170, 170);
colors[8] = gdImageColorAllocate(im_Binary, 85, 85, 85);
colors[9] = gdImageColorAllocate(im_Binary, 85, 85, 255);
colors[10] = gdImageColorAllocate(im_Binary, 85, 255, 85);
colors[11] = gdImageColorAllocate(im_Binary, 85, 255, 255);
colors[12] = gdImageColorAllocate(im_Binary, 255, 85, 85);
colors[13] = gdImageColorAllocate(im_Binary, 255, 85, 255);
colors[14] = gdImageColorAllocate(im_Binary, 255, 255, 85);
colors[15] = gdImageColorAllocate(im_Binary, 255, 255, 255);
colors[0] = gdImageColorAllocate(canvas, 0, 0, 0);
colors[1] = gdImageColorAllocate(canvas, 0, 0, 170);
colors[2] = gdImageColorAllocate(canvas, 0, 170, 0);
colors[3] = gdImageColorAllocate(canvas, 0, 170, 170);
colors[4] = gdImageColorAllocate(canvas, 170, 0, 0);
colors[5] = gdImageColorAllocate(canvas, 170, 0, 170);
colors[6] = gdImageColorAllocate(canvas, 170, 85, 0);
colors[7] = gdImageColorAllocate(canvas, 170, 170, 170);
colors[8] = gdImageColorAllocate(canvas, 85, 85, 85);
colors[9] = gdImageColorAllocate(canvas, 85, 85, 255);
colors[10] = gdImageColorAllocate(canvas, 85, 255, 85);
colors[11] = gdImageColorAllocate(canvas, 85, 255, 255);
colors[12] = gdImageColorAllocate(canvas, 255, 85, 85);
colors[13] = gdImageColorAllocate(canvas, 255, 85, 255);
colors[14] = gdImageColorAllocate(canvas, 255, 255, 85);
colors[15] = gdImageColorAllocate(canvas, 255, 255, 255);

// process binary
int32_t character, attribute, background, foreground;
Expand All @@ -77,13 +77,13 @@ void binary(unsigned char *inputFileBuffer, int32_t inputFileSize, char *outputF
background -= 8;
}

alDrawChar(im_Binary, fontData.font_data, bits, fontData.height,
alDrawChar(canvas, fontData.font_data, bits, fontData.height,
position_x, position_y, colors[background], colors[foreground], character);

position_x++;
loop+=2;
}

// create output image
output(im_Binary, outputFile, retinaout, createRetinaRep);
output(canvas, outputFile, retinaout, createRetinaRep);
}
14 changes: 7 additions & 7 deletions src/loaders/icedraw.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void icedraw(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output
int32_t x2 = (inputFileBuffer[9] << 8) + inputFileBuffer[8];

// libgd image pointers
gdImagePtr im_IDF;
gdImagePtr canvas;

int32_t loop;
int32_t index;
Expand Down Expand Up @@ -95,20 +95,20 @@ void icedraw(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output
}

// create IDF instance
im_IDF = gdImageCreate((x2 + 1) * 8, i / 2 / 80 * 16);
canvas = gdImageCreate((x2 + 1) * 8, i / 2 / 80 * 16);

// error output
if (!im_IDF) {
if (!canvas) {
perror("Can't allocate buffer image memory");
exit (9);
}
gdImageColorAllocate(im_IDF, 0, 0, 0);
gdImageColorAllocate(canvas, 0, 0, 0);

// process IDF palette
for (loop = 0; loop < 16; loop++)
{
index = (loop * 3) + inputFileSize - 48;
colors[loop] = gdImageColorAllocate(im_IDF, (inputFileBuffer[index] << 2 | inputFileBuffer[index] >> 4),
colors[loop] = gdImageColorAllocate(canvas, (inputFileBuffer[index] << 2 | inputFileBuffer[index] >> 4),
(inputFileBuffer[index + 1] << 2 | inputFileBuffer[index + 1] >> 4),
(inputFileBuffer[index + 2] << 2 | inputFileBuffer[index + 2] >> 4));
}
Expand All @@ -131,13 +131,13 @@ void icedraw(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output
background = (attribute & 240) >> 4;
foreground = attribute & 15;

alDrawChar(im_IDF, font_data, 8, 16, position_x, position_y, colors[background], colors[foreground], character);
alDrawChar(canvas, font_data, 8, 16, position_x, position_y, colors[background], colors[foreground], character);

position_x++;
}

// create output file
output(im_IDF, outputFile, retinaout, createRetinaRep);
output(canvas, outputFile, retinaout, createRetinaRep);

// free memory
free(font_data_idf);
Expand Down
44 changes: 22 additions & 22 deletions src/loaders/pcboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void pcboard(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output
alSelectFont(&fontData, font);

// libgd image pointers
gdImagePtr im_PCB;
gdImagePtr canvas;

// process PCBoard
int32_t character, current_character, next_character;
Expand Down Expand Up @@ -144,31 +144,31 @@ void pcboard(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output
position_y_max++;

// allocate buffer image memory
im_PCB = gdImageCreate(columns * bits, (position_y_max)*fontData.height);
canvas = gdImageCreate(columns * bits, (position_y_max)*fontData.height);

// allocate black color and create background canvas
gdImageColorAllocate(im_PCB, 0, 0, 0);
gdImageFill(im_PCB, 0, 0, 0);
gdImageColorAllocate(canvas, 0, 0, 0);
gdImageFill(canvas, 0, 0, 0);

// allocate color palette
int32_t colors[71];

colors[48] = gdImageColorAllocate(im_PCB, 0, 0, 0);
colors[49] = gdImageColorAllocate(im_PCB, 0, 0, 170);
colors[50] = gdImageColorAllocate(im_PCB, 0, 170, 0);
colors[51] = gdImageColorAllocate(im_PCB, 0, 170, 170);
colors[52] = gdImageColorAllocate(im_PCB, 170, 0, 0);
colors[53] = gdImageColorAllocate(im_PCB, 170, 0, 170);
colors[54] = gdImageColorAllocate(im_PCB, 170, 85, 0);
colors[55] = gdImageColorAllocate(im_PCB, 170, 170, 170);
colors[56] = gdImageColorAllocate(im_PCB, 85, 85, 85);
colors[57] = gdImageColorAllocate(im_PCB, 85, 85, 255);
colors[65] = gdImageColorAllocate(im_PCB, 85, 255, 85);
colors[66] = gdImageColorAllocate(im_PCB, 85, 255, 255);
colors[67] = gdImageColorAllocate(im_PCB, 255, 85, 85);
colors[68] = gdImageColorAllocate(im_PCB, 255, 85, 255);
colors[69] = gdImageColorAllocate(im_PCB, 255, 255, 85);
colors[70] = gdImageColorAllocate(im_PCB, 255, 255, 255);
colors[48] = gdImageColorAllocate(canvas, 0, 0, 0);
colors[49] = gdImageColorAllocate(canvas, 0, 0, 170);
colors[50] = gdImageColorAllocate(canvas, 0, 170, 0);
colors[51] = gdImageColorAllocate(canvas, 0, 170, 170);
colors[52] = gdImageColorAllocate(canvas, 170, 0, 0);
colors[53] = gdImageColorAllocate(canvas, 170, 0, 170);
colors[54] = gdImageColorAllocate(canvas, 170, 85, 0);
colors[55] = gdImageColorAllocate(canvas, 170, 170, 170);
colors[56] = gdImageColorAllocate(canvas, 85, 85, 85);
colors[57] = gdImageColorAllocate(canvas, 85, 85, 255);
colors[65] = gdImageColorAllocate(canvas, 85, 255, 85);
colors[66] = gdImageColorAllocate(canvas, 85, 255, 255);
colors[67] = gdImageColorAllocate(canvas, 255, 85, 85);
colors[68] = gdImageColorAllocate(canvas, 255, 85, 255);
colors[69] = gdImageColorAllocate(canvas, 255, 255, 85);
colors[70] = gdImageColorAllocate(canvas, 255, 255, 255);

// the last value of loop tells us how many items are stored in there
int32_t pcbBufferItems = structIndex;
Expand All @@ -183,12 +183,12 @@ void pcboard(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output
foreground = pcboard_buffer[loop].foreground;
character = pcboard_buffer[loop].current_character;

alDrawChar(im_PCB, fontData.font_data, bits, fontData.height,
alDrawChar(canvas, fontData.font_data, bits, fontData.height,
position_x, position_y, colors[background], colors[foreground], character);
}

// create output image
output(im_PCB, outputFile, retinaout, createRetinaRep);
output(canvas, outputFile, retinaout, createRetinaRep);

// free memory
free(pcboard_buffer);
Expand Down
Loading

0 comments on commit b9ddd74

Please sign in to comment.