diff --git a/main/main.cpp b/main/main.cpp index 97206fe..d3a7806 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -64,7 +64,7 @@ #include "../src/Imagedisplay.hpp" #include - +void outPutPixel(int windowHeight, int windowWidth); int main(){ @@ -76,23 +76,23 @@ int main(){ std::cout <<"picture" << std::endl; vkvm::Color backgroundColor = vkvm::getBackgroundColor(); for(int i = 0; i<1000; i++) { - Imagedisplay imagedisplay("src/P1.bmp"); - imagedisplay.load("src/P1.bmp"); - for (int w; w < vkvm::getWidth(); w++) { - for (int h; h < vkvm::getHeight(); h++) { + Imagedisplay imagedisplay("../src/P6.bmp"); + for (int w = 0; w < vkvm::getWidth(); w++) { + for (int h = 0; h < vkvm::getHeight(); h++) { unsigned int a ; a = imagedisplay.getPixel(w, h); vkvm::setPixel(w,h,vkvm::Color(a)); } } + outPutPixel(vkvm::getHeight() ,vkvm::getWidth()); sleep(5); vkvm::setDefaultValues(); - Imagedisplay imagedisplay2("src/P2.bmp"); - imagedisplay2.load("src/P2.bmp"); - for (int w; w < vkvm::getWidth(); w++) { - for (int h; h < vkvm::getHeight(); h++) { + Imagedisplay imagedisplay2("../src/P7.bmp"); + + for (int w = 0; w < vkvm::getWidth(); w++) { + for (int h = 0; h < vkvm::getHeight(); h++) { unsigned int a ; a = imagedisplay2.getPixel(w, h); vkvm::setPixel(w,h,vkvm::Color(a)); @@ -101,10 +101,9 @@ int main(){ sleep(5); vkvm::setDefaultValues(); - Imagedisplay imagedisplay3("src/P3.bmp"); - imagedisplay3.load("src/P3.bmp"); - for (int w; w < vkvm::getWidth(); w++) { - for (int h; h < vkvm::getHeight(); h++){ + Imagedisplay imagedisplay3("../src/P6.bmp"); + for (int w = 0; w < vkvm::getWidth(); w++) { + for (int h = 0; h < vkvm::getHeight(); h++){ unsigned int a ; a = imagedisplay3.getPixel(w, h); vkvm::setPixel(w,h,vkvm::Color(a)); @@ -114,10 +113,9 @@ int main(){ sleep(5); vkvm::setDefaultValues(); - Imagedisplay imagedisplay4("src/P4.bmp"); - imagedisplay4.load("src/P4.bmp"); - for (int w; w < vkvm::getWidth(); w++) { - for (int h; h < vkvm::getHeight(); h++){ + Imagedisplay imagedisplay4("../src/P7.bmp"); + for (int w = 0; w < vkvm::getWidth(); w++) { + for (int h = 0; h < vkvm::getHeight(); h++){ unsigned int a ; a = imagedisplay4.getPixel(w, h); vkvm::setPixel(w,h,vkvm::Color(a)); @@ -130,4 +128,18 @@ int main(){ }); vkvm::callEvent(vkvm::Timer); +} + + +void outPutPixel(int windowHeight, int windowWidth) { + for(int y = 0; y < windowHeight; y++) { + for(int x = 0; x < windowWidth; x++) { + if(vkvm::getPixel(x, y).getRed() !=0) { + std::cout << "*"; + } else { + std::cout << " "; + } + } + std::cout << "\n"; + } } \ No newline at end of file diff --git a/src/Imagedisplay.cpp b/src/Imagedisplay.cpp index 3f2aad3..901777f 100644 --- a/src/Imagedisplay.cpp +++ b/src/Imagedisplay.cpp @@ -29,7 +29,6 @@ void Imagedisplay::load(const std::string &file) { for(int i = 0; i < str.size();i++){ data[i] = str[i]; } - offset = (int)*(unsigned int*)(&data[10]); width = (int)*(unsigned int*)(&data[18]); height = (int)*(unsigned int*)(&data[22]); @@ -58,9 +57,11 @@ unsigned int Imagedisplay::getPixel(int x, int y) { char *ptr = getData() + ((getHeight() - 1 - y) * getWidth() + x) * (getBitsPerPixel() / 8); for(int i = 0; i < getBitsPerPixel() / 8;i++){ *((char*)&pixel+i) = ptr[i]; + std::cout<< "hi: im" << (unsigned int) ptr[i]<< std::endl; } if(pixel != 0){ return pixel; } + return pixel; } diff --git a/src/P1.bmp b/src/P1.bmp deleted file mode 100644 index 9091f54..0000000 Binary files a/src/P1.bmp and /dev/null differ diff --git a/src/P2.bmp b/src/P2.bmp deleted file mode 100644 index 94f6779..0000000 Binary files a/src/P2.bmp and /dev/null differ diff --git a/src/P3.bmp b/src/P3.bmp deleted file mode 100644 index 24751c3..0000000 Binary files a/src/P3.bmp and /dev/null differ diff --git a/src/P4.bmp b/src/P4.bmp deleted file mode 100644 index 3735ab9..0000000 Binary files a/src/P4.bmp and /dev/null differ