]> Creatis software - gdcm.git/blobdiff - Example/TestWrite.cxx
ENH: update dvpt version
[gdcm.git] / Example / TestWrite.cxx
index 9673abf03387600ce14f32240cf69c1ba60f7f17..5e58ac2d9404b14a27f70924dbd841e5173361da 100644 (file)
@@ -1,9 +1,6 @@
 #include <iostream>
-#include "gdcm.h"
-#include "gdcmHeader.h"
-#include "gdcmDocument.h"
-
 #include <stdio.h>
+#include "gdcm.h"
 
 int main(int argc, char* argv[])
 {  
@@ -22,9 +19,11 @@ int main(int argc, char* argv[])
          std::cerr << "usage: " << std::endl 
                    << argv[0] << " fileName writtingMode "
                 << std::endl 
-                   << "(a : ACR, d : DICOM Implicit VR,"
-                   << " x : DICOM Explicit VR  r : RAW)"
+                   << "(a : ACR, gives fileNamed : DICOM Implicit VR,"
+                   << " x : DICOM Explicit VR  r : RAW,"
+                   << " v : explicit VR + computes the video inv image"
                 << std::endl;
+
          return 0;
    }
 /*
@@ -49,8 +48,9 @@ int main(int argc, char* argv[])
      
    toto = argv[1]; 
 
-   e1 = new gdcmHeader(toto.c_str(), false, true);
-   if (!e1->IsReadable()) {
+   e1 = new gdcmHeader( toto.c_str() );
+   if (!e1->IsReadable())
+   {
        std::cerr << "Sorry, not a Readable DICOM / ACR File"  <<std::endl;
        return 0;
    }
@@ -134,6 +134,22 @@ int main(int argc, char* argv[])
       f1->WriteRawData(zozo);
       break;
 
+   case 'v' :
+
+     if ( f1->GetHeader()->GetBitsStored() == 8)
+        for (int i=0; i<dataSize; i++) {
+           ((char *)imageData)[i] += 127;
+        }
+     else  
+        for (int i=0; i<dataSize/2; i++) {
+           ((unsigned short *)imageData)[i] += 32767;
+        }
+
+         sprintf(zozo, "%s.DCM", toto.c_str());
+         printf ("WriteDCM Implicit VR\n");
+         f1->WriteDcmImplVR(zozo);
+         break;
+
    }
   return 0;
 }