Merge pull request #2122 from loebl/bug/wrong-color-import-in-3mf

Correct 3MF displaycolor import
pull/2132/head
Kim Kulling 2018-09-05 17:04:02 +02:00 committed by GitHub
commit a7c13eef2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 5 deletions

View File

@ -297,8 +297,9 @@ private:
return false;
}
//format of the color string: #RRGGBBAA or #RRGGBB (3MF Core chapter 5.1.1)
const size_t len( strlen( color ) );
if ( 9 != len ) {
if ( 9 != len && 7 != len) {
return false;
}
@ -313,26 +314,28 @@ private:
++buf;
comp[ 1 ] = *buf;
++buf;
diffuse.r = static_cast<ai_real>( strtol( comp, NULL, 16 ) );
diffuse.r = static_cast<ai_real>( strtol( comp, NULL, 16 ) ) / 255.0;
comp[ 0 ] = *buf;
++buf;
comp[ 1 ] = *buf;
++buf;
diffuse.g = static_cast< ai_real >( strtol( comp, NULL, 16 ) );
diffuse.g = static_cast< ai_real >( strtol( comp, NULL, 16 ) ) / 255.0;
comp[ 0 ] = *buf;
++buf;
comp[ 1 ] = *buf;
++buf;
diffuse.b = static_cast< ai_real >( strtol( comp, NULL, 16 ) );
diffuse.b = static_cast< ai_real >( strtol( comp, NULL, 16 ) ) / 255.0;
if(7 == len)
return true;
comp[ 0 ] = *buf;
++buf;
comp[ 1 ] = *buf;
++buf;
diffuse.a = static_cast< ai_real >( strtol( comp, NULL, 16 ) );
diffuse.a = static_cast< ai_real >( strtol( comp, NULL, 16 ) ) / 255.0;
return true;
}