#include "font.h" #include #include #include int main(void) { char strings[5][26] = { "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz", "0123456789 +- !?.,:=' ", " ", " Hello, World! 1-2+3=2 ", }; int w = 26 * 6 + 20; int h = 5 * 6 + 20; uint8_t img[h][w]; memset(&img, 0, sizeof(img)); for (int line = 0; line < 5; line++) { for (int chr = 0; chr < 26; chr++) { const uint8_t* sym = fnt_get_sym(strings[line][chr]); if (!sym) continue; for (int byte = 0; byte < 5; byte++) { uint8_t data = sym[byte]; for (int bit = 0; bit < 6; bit++) { uint8_t pix = (data << bit) & 0b100000; img[line*6 + byte + 10][chr*6 + bit + 10] = pix?255:0; } } } } char* filename = "demo.tif"; TIFF* image = TIFFOpen(filename, "w"); // Setup TIFFSetField(image, TIFFTAG_IMAGEWIDTH, w); TIFFSetField(image, TIFFTAG_IMAGELENGTH, h); TIFFSetField(image, TIFFTAG_BITSPERSAMPLE, 8); TIFFSetField(image, TIFFTAG_ROWSPERSTRIP, 1); TIFFSetField(image, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); TIFFSetField(image, TIFFTAG_SAMPLESPERPIXEL, 1); // Write pixels for (int y = 0; y < h; y++) TIFFWriteScanline(image, img[y], y, 0); // Clean up TIFFClose(image); printf("All done! Output is in '%s'\n", filename); return 0; }