]> Creatis software - gdcm.git/commitdiff
gdcmHeaderHelper::GetNumberOfScalarComponents() added, to allow displaying RGB images...
authorjpr <jpr>
Fri, 3 Oct 2003 14:26:11 +0000 (14:26 +0000)
committerjpr <jpr>
Fri, 3 Oct 2003 14:26:11 +0000 (14:26 +0000)
src/gdcmFile.cxx
src/gdcmHeaderHelper.cxx
src/gdcmHeaderHelper.h

index 1051765fd8061ae42070ae335f06d38185353716..88dcdf6a04a02a7ac6ad7fac2db59db677c6674a 100644 (file)
@@ -426,14 +426,14 @@ size_t gdcmFile::GetImageDataIntoVector (void* destination, size_t MaxSize) {
          return (size_t)0; 
       }
    } 
+
 // Just to 'see' was was actually read on disk :-(
 // Some troubles expected
 
-//FILE *  fpSpurious;
-//fpSpurious=fopen("SpuriousFile.raw","w"); 
-//fwrite(destination,lgrTotale, 1,fpSpurious);
-//fclose(fpSpurious);
-
+FILE *  fpSpurious;
+fpSpurious=fopen("SpuriousFile.raw","w"); 
+fwrite(destination,lgrTotale, 1,fpSpurious);
+fclose(fpSpurious);
 
 
    // *Try* to deal with the color
@@ -444,7 +444,7 @@ size_t gdcmFile::GetImageDataIntoVector (void* destination, size_t MaxSize) {
    // Planar configuration = 2 : 1 gray Plane + 3 LUT
 
    // Well ... supposed to be !
-   // See US-PAL-8-10x-echo.dcm, PlanarConfiguration=0,PhotometricInterpretation=PALETTE COLOR
+   // See US-PAL-8-10x-echo.dcm: PlanarConfiguration=0,PhotometricInterpretation=PALETTE COLOR
    // and heuristic has to be found :-( 
 
       std::string str_PhotometricInterpretation = gdcmHeader::GetPubElValByNumber(0x0028,0x0004);
index 3508803987222a9318487e0c66f4afdca3d9a26f..cb4b3559e582b36b460afb458a66ac30cd3690ba 100644 (file)
@@ -1,4 +1,4 @@
-// $Header: /cvs/public/gdcm/src/Attic/gdcmHeaderHelper.cxx,v 1.9 2003/10/02 11:26:16 malaterre Exp $
+// $Header: /cvs/public/gdcm/src/Attic/gdcmHeaderHelper.cxx,v 1.10 2003/10/03 14:26:11 jpr Exp $
 
 #include "gdcmHeaderHelper.h"
 
@@ -89,6 +89,26 @@ int gdcmHeaderHelper::GetPixelSize() {
    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 !
+
+      if (PhotometricInterpretation == GDCM_UNFOUND) return 1;
+      if (PhotometricInterpretation == "MONOCHROME1") return 1;
+      if (PhotometricInterpretation == "MONOCHROME2") return 1;
+
+      return 3;
+}
 //----------------------------------------------------------------------------
 /**
  * \ingroup gdcmHeaderHelper
index ab5807c6b30f6fd720a3feaf8ae59cf57194ab59..06455a49d9cd88856c1c20c5c878a67acd1ebe1b 100644 (file)
@@ -1,4 +1,4 @@
-// $Header: /cvs/public/gdcm/src/Attic/gdcmHeaderHelper.h,v 1.3 2003/09/11 13:44:17 jpr Exp $
+// $Header: /cvs/public/gdcm/src/Attic/gdcmHeaderHelper.h,v 1.4 2003/10/03 14:26:11 jpr Exp $
 
 #ifndef GDCMHEADERHELPER_H
 #define GDCMHEADERHELPER_H
@@ -76,7 +76,9 @@ public:
    float GetXSpacing();
    float GetYSpacing();
    float GetZSpacing();
-   
+
+   int GetNumberOfScalarComponents();
+
    std::string GetStudyUID();
    std::string GetSeriesUID();
    std::string GetClassUID();
@@ -96,6 +98,7 @@ public:
    ModalityType GetModality();
    
    void GetImageOrientationPatient( float* iop );
+  
 
 };