#include #include "add.h" #include "Bitmap.h" /** * @author: Julian Hinxlage * @since: v0.0.0 * @brief: An image is loaded and used as a font. * A string is converted and displayed in the console. * Currently only to test. */ int main() { Bitmap bitmap; bitmap.load("../res/font.bmp"); std::string str; std::cout << "string to draw: "; std::cin >> str; //values used to calculate the coordinates of the characters int xOffset = 2; int yOffset = 2; int xSize = 5; int ySize = 7; int xCount = 18; int xStart = 1; int yStart = 2; //print vertical //i is the current row for (int i = 0; i < ySize; i++) { //loop through the characters in the string for (char c : str) { //index of character(x and y) int index = (c - ' '); int xIndex = index % xCount; int yIndex = index / xCount; //character index to pixel index conversion int x = xIndex * (xSize + xOffset) + xStart; int y = yIndex * (ySize + yOffset) + yStart; //print current row of the current character for (int j = x; j < x + xSize; j++) { char *pixel_ptr = bitmap.getPixel(j, i + y); unsigned int pixel = 0; *((char*)&pixel+0) = pixel_ptr[0]; *((char*)&pixel+1) = pixel_ptr[1]; *((char*)&pixel+2) = pixel_ptr[2]; if (pixel == 0) { std::cout << " "; } else { std::cout << "1"; } } std::cout << " "; } std::cout << std::endl; } return 0; }