From 2ee09b2528103d8cda0a6bb75f6199cfd4d0e74b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20L=C3=B6ber?= Date: Wed, 5 Sep 2018 15:49:15 +0200 Subject: [PATCH] Correct 3MF displaycolor import --- code/D3MFImporter.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/code/D3MFImporter.cpp b/code/D3MFImporter.cpp index e02c5f41d..e1a0d92d0 100644 --- a/code/D3MFImporter.cpp +++ b/code/D3MFImporter.cpp @@ -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( strtol( comp, NULL, 16 ) ); + diffuse.r = static_cast( 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; }