X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmHeaderHelper.cxx;h=2917c573c430fc59972c85a7f911f4afa487f9b2;hb=eb46f178c8cd7efca6bc149bcd95c41a4a3704f2;hp=cb4b3559e582b36b460afb458a66ac30cd3690ba;hpb=f8e5982fc2d53058d72b5c96e8f4f53faf9a37d7;p=gdcm.git diff --git a/src/gdcmHeaderHelper.cxx b/src/gdcmHeaderHelper.cxx index cb4b3559..2917c573 100644 --- a/src/gdcmHeaderHelper.cxx +++ b/src/gdcmHeaderHelper.cxx @@ -1,4 +1,4 @@ -// $Header: /cvs/public/gdcm/src/Attic/gdcmHeaderHelper.cxx,v 1.10 2003/10/03 14:26:11 jpr Exp $ +// $Header: /cvs/public/gdcm/src/Attic/gdcmHeaderHelper.cxx,v 1.12 2003/10/06 15:32:48 malaterre Exp $ #include "gdcmHeaderHelper.h" @@ -101,11 +101,13 @@ int gdcmHeaderHelper::GetNumberOfScalarComponents() { std::string PhotometricInterpretation = gdcmHeader::GetPubElValByNumber(0x0028,0x0004); + // The compiler will optimze, if it feels like ! - if (PhotometricInterpretation == GDCM_UNFOUND) return 1; - if (PhotometricInterpretation == "MONOCHROME1") return 1; - if (PhotometricInterpretation == "MONOCHROME2") return 1; + //beware of trailing space at end of string + if (PhotometricInterpretation.find(GDCM_UNFOUND) < PhotometricInterpretation.length() || + PhotometricInterpretation.find("MONOCHROME1") < PhotometricInterpretation.length() || + PhotometricInterpretation.find("MONOCHROME2") < PhotometricInterpretation.length() ) return 1; return 3; } @@ -161,7 +163,7 @@ float gdcmHeaderHelper::GetXSpacing() { dbg.Verbose(0, "gdcmHeader::GetXSpacing: unfound Pixel Spacing (0028,0030)"); return 1.; } - if( sscanf( StrSpacing.c_str(), "%f\\%f", &xspacing, &yspacing) != 2) + if( sscanf( StrSpacing.c_str(), "%f\\%f", &yspacing, &xspacing) != 2) return 0.; //else return xspacing; @@ -181,12 +183,12 @@ float gdcmHeaderHelper::GetYSpacing() { dbg.Verbose(0, "gdcmHeader::GetYSpacing: unfound Pixel Spacing (0028,0030)"); return 1.; } - if( sscanf( StrSpacing.c_str(), "%f\\%f", &xspacing, &yspacing) != 2) + if( sscanf( StrSpacing.c_str(), "%f\\%f", &yspacing, &xspacing) != 2) return 0.; if (yspacing == 0.) { dbg.Verbose(0, "gdcmHeader::GetYSpacing: gdcmData/CT-MONO2-8-abdo.dcm problem"); // seems to be a bug in the header ... - sscanf( StrSpacing.c_str(), "%f\\0\\%f", &xspacing, &yspacing); + sscanf( StrSpacing.c_str(), "%f\\0\\%f", &yspacing, &xspacing); } return yspacing; }