fixed pixel value bug

This commit is contained in:
Julian Hinxlage 2019-10-16 12:17:59 +02:00
parent 4841423c79
commit 491acaada1
1 changed files with 15 additions and 7 deletions

View File

@ -14,15 +14,17 @@ int main() {
Bitmap bitmap;
bitmap.load("../res/font.bmp");
std::string str = "Hello, World!";
std::string str;
std::cout << "string to draw: ";
std::cin >> str;
//values used to calculate the coordinates of the characters
int xOffset = 1;
int xOffset = 2;
int yOffset = 2;
int xSize = 6;
int xSize = 5;
int ySize = 7;
int xCount = 18;
int xStart = 0;
int xStart = 1;
int yStart = 2;
//print vertical
@ -41,12 +43,18 @@ int main() {
//print current row of the current character
for (int j = x; j < x + xSize; j++) {
auto *pixel = (unsigned int *) bitmap.getPixel(j, i + y);
if (*pixel == 0) {
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 << " ";
}