MCPcopy Create free account
hub / github.com/CruiserOne/Astrolog / WriteXBitmap

Function WriteXBitmap

xdevice.cpp:1010–1065  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1008// defines how much white space is put in the file.
1009
1010void WriteXBitmap(FILE *file, CONST char *szName, char mode)
1011{
1012 int x, y, i, temp = 0;
1013 uint value;
1014 char szT[cchSzDef], *pchStart, *pchEnd;
1015
1016 // Determine variable name from filename.
1017 sprintf(szT, "%s", szName);
1018 for (pchEnd = szT; *pchEnd != chNull; pchEnd++)
1019 ;
1020 for (pchStart = pchEnd; pchStart > szT &&
1021 *(pchStart-1) != '/' && *(pchStart-1) != '\\'; pchStart--)
1022 ;
1023 for (pchEnd = pchStart; *pchEnd != chNull && *pchEnd != '.'; pchEnd++)
1024 ;
1025 *pchEnd = chNull;
1026
1027 // Output file header.
1028 fprintf(file, "#define %s_width %d\n" , pchStart, gs.xWin);
1029 fprintf(file, "#define %s_height %d\n", pchStart, gs.yWin);
1030 fprintf(file, "static %s %s_bits[] = {",
1031 mode != 'V' ? "char" : "short", pchStart);
1032 for (y = 0; y < gs.yWin; y++) {
1033 x = 0;
1034 do {
1035
1036 // Process each row, eight columns at a time.
1037 if (y + x > 0)
1038 fprintf(file, ",");
1039 if (temp == 0)
1040 fprintf(file, "\n%s",
1041 mode == 'N' ? " " : (mode == 'C' ? " " : ""));
1042 value = 0;
1043 for (i = (mode != 'V' ? 7 : 15); i >= 0; i--)
1044 value = (value << 1) + (!(BmGetXY(x+i, y)^
1045 (gs.fInverse*15))^gs.fInverse && (x + i < gs.xWin));
1046 if (mode == 'N')
1047 putc(' ', file);
1048 fprintf(file, "0x");
1049 if (mode == 'V')
1050 fprintf(file, "%c%c",
1051 ChHex(value >> 12), ChHex((value >> 8) & 15));
1052 fprintf(file, "%c%c",
1053 ChHex((value >> 4) & 15), ChHex(value & 15));
1054 temp++;
1055
1056 // Is it time to skip to the next line while writing the file yet?
1057 if ((mode == 'N' && temp >= 12) ||
1058 (mode == 'C' && temp >= 15) ||
1059 (mode == 'V' && temp >= 11))
1060 temp = 0;
1061 x += (mode != 'V' ? 8 : 16);
1062 } while (x < gs.xWin);
1063 }
1064 fprintf(file, "};\n");
1065}
1066
1067

Callers 1

EndFileXFunction · 0.85

Calls 1

BmGetXYFunction · 0.85

Tested by

no test coverage detected