From 98e78b915e19ba2d15fcabe36413826999c70a2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20F=C3=BCndgens?= Date: Tue, 2 Dec 2014 13:37:31 +0100 Subject: [PATCH] adjusting converter to work with black and white image backgrounds --- converter/converter.hh | 8 ++++---- converter/main.cc | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/converter/converter.hh b/converter/converter.hh index 32c5c42..d0d2e62 100644 --- a/converter/converter.hh +++ b/converter/converter.hh @@ -11,11 +11,11 @@ class Converter { Converter(std::string level); Converter(); ~Converter(); - void updateComposition(unsigned int idG, unsigned int idB, float posX, float posZ); - std::vector newComposition(unsigned int type, float posX, float posZ); + void updateComposition(unsigned int idG, unsigned int idB, float posX, float posZ); //updates the position of a composition + std::vector newComposition(unsigned int type, float posX, float posZ);//creates a new composition and returns its ID void deleteComposition(unsigned int idG, unsigned int idB); - void save(); - std::vector getNextID(); + void save(); //writes the xml to file + std::vector getNextID(); //returns the next unused ID private: std::vector nextID; diff --git a/converter/main.cc b/converter/main.cc index 70eeb55..88a6eb4 100644 --- a/converter/main.cc +++ b/converter/main.cc @@ -31,8 +31,8 @@ int main( int argc, char *argv[] ){ for(unsigned int columnNum = 0; columnNum < width; columnNum++){ unsigned int pixel = (rowNum*width+columnNum)*4; //if there is a composition here, adjust the xml and image - if(image[pixel]!=0){ - if(image[pixel+1]==0 && image[pixel+2]==0){ + if(image[pixel]!=0 && image[pixel]!=255){ + if((image[pixel+1]==0 && image[pixel+2]==0) || (image[pixel+1]==255 && image[pixel+2]==255)){ std::vector temp; temp = conv.newComposition(image[pixel], 0.5+rowNum-0.5*height, 0.5+columnNum-0.5*width); idFound[temp[0]][temp[1]] = true;