-// $Header: /cvs/public/gdcm/src/Attic/gdcmHeaderHelper.cxx,v 1.8 2003/09/24 16:46:38 jpr Exp $
-
-//This is needed when compiling in debug mode
-#ifdef _MSC_VER
-#pragma warning ( disable : 4800 )
-// 'identifier' : class 'type' needs to have dll-interface to be used by
-// clients of class 'type2'
-#pragma warning ( disable : 4251 )
-// 'identifier' : identifier was truncated to 'number' characters in the
-// debug information
-#pragma warning ( disable : 4786 )
-#endif //_MSC_VER
+// $Header: /cvs/public/gdcm/src/Attic/gdcmHeaderHelper.cxx,v 1.12 2003/10/06 15:32:48 malaterre Exp $
#include "gdcmHeaderHelper.h"
+
#include "gdcmUtil.h" //for debug
#include <math.h>
#include <algorithm>
dbg.Verbose(0, "gdcmHeader::GetPixelSize: Unknown pixel type");
return 0;
}
+
+//----------------------------------------------------------------------------
+/**
+ * \ingroup gdcmHeaderHelper
+ * \brief gets the info from 0028,0004 : Photometric Interp
+ * \ else 1.
+ * @return 1 if Gray level, 3 if Color
+ */
+int gdcmHeaderHelper::GetNumberOfScalarComponents() {
+ std::string PhotometricInterpretation =
+ gdcmHeader::GetPubElValByNumber(0x0028,0x0004);
+
+
+// The compiler will optimze, if it feels like !
+
+ //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;
+}
//----------------------------------------------------------------------------
/**
* \ingroup gdcmHeaderHelper
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;
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;
}