adjusting converter to work with black and white image backgrounds

This commit is contained in:
Steffen Fündgens 2014-12-02 13:37:31 +01:00
parent a8457d9399
commit 98e78b915e
2 changed files with 6 additions and 6 deletions

View File

@ -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<unsigned int> 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<unsigned int> 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<unsigned int> getNextID();
void save(); //writes the xml to file
std::vector<unsigned int> getNextID(); //returns the next unused ID
private:
std::vector<unsigned int> nextID;

View File

@ -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<unsigned int> temp;
temp = conv.newComposition(image[pixel], 0.5+rowNum-0.5*height, 0.5+columnNum-0.5*width);
idFound[temp[0]][temp[1]] = true;