dev
This commit is contained in:
parent
8ef788ab64
commit
95b45bdce2
@ -64,7 +64,7 @@
|
||||
#include "../src/Imagedisplay.hpp"
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
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";
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
BIN
src/P1.bmp
BIN
src/P1.bmp
Binary file not shown.
Before Width: | Height: | Size: 62 KiB |
BIN
src/P2.bmp
BIN
src/P2.bmp
Binary file not shown.
Before Width: | Height: | Size: 50 KiB |
BIN
src/P3.bmp
BIN
src/P3.bmp
Binary file not shown.
Before Width: | Height: | Size: 31 KiB |
BIN
src/P4.bmp
BIN
src/P4.bmp
Binary file not shown.
Before Width: | Height: | Size: 30 KiB |
Loading…
Reference in New Issue
Block a user