]> Creatis software - gdcm.git/blobdiff - Example/exReadPapyrus.cxx
Some wrecked ACR-NEMA-like images begin by group 0028 (?!?)
[gdcm.git] / Example / exReadPapyrus.cxx
index 185c84ae20d06e3b4af4d4c2fb361476b0b0ea65..dcde6b828afa596745c3cfaf973ed7d6f34a52e4 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: exReadPapyrus.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/18 08:35:44 $
-  Version:   $Revision: 1.4 $
+  Date:      $Date: 2006/08/29 14:39:45 $
+  Version:   $Revision: 1.7 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -74,13 +74,15 @@ int main(int argc, char *argv[])
 {
 
    START_USAGE(usage)
-   " \n exReadPapyrus :\n",
-   " Reads a Papyrus V3 File, Writes a Multiframe Dicoim V3 File ",
-   "     (just to show gdcm can do it ...)               ",
+   " \n exReadPapyrus :\n                                       ",
+   " Reads a Papyrus V3 File, Writes a Multiframe Dicom V3 File ",
+   "     (just to show gdcm can do it ...)                      ", 
+   "     ==> Well ... It does, but not too much! ",
+   "     ==> This code assumes that Pixel Data is uncompressed; no check is performed :-(",
    "",
    " usage: exReadPapyrus filein=inputPapyrusFileName fileout=outputDicomFileName", 
    "                      [debug]  ", 
-   "        debug    : user wants to run the program in 'debug mode'        ",
+   "        debug    : developper wants to run the program in 'debug mode'        ",
    FINISH_USAGE
 
 
@@ -133,14 +135,14 @@ int main(int argc, char *argv[])
    }
 
    int loadMode = 0x0; // load everything
-   gdcm::File *f = new gdcm::File();
+   gdcm::File *f = gdcm::File::New();
    f->SetLoadMode( loadMode );
    f->SetFileName( fileName );
    bool res = f->Load();  
 
    if ( !res )
    {
-      delete f;
+      f->Delete();
       return 0;
    }
 
@@ -149,7 +151,7 @@ int main(int argc, char *argv[])
    if (!seqPapyrus)
    {
       std::cout << "NOT a Papyrus File : " << fileName <<std::endl;
-      delete f;
+      f->Delete();
       return 1;
    }
 
@@ -162,7 +164,7 @@ int main(int argc, char *argv[])
    {
       std::cout << "NO SQItem found within private Papyrus Sequence"
           << std::endl;
-      delete f;
+      f->Delete();
       return 1;
    }
       
@@ -232,7 +234,6 @@ int main(int argc, char *argv[])
    if( ! *Fp )
    {
       std::cout <<  "Cannot open file: " << fileName << std::endl;
-      //gdcmDebugMacro( "Cannot open file: " << fileName.c_str() );
       delete Fp;
       Fp = 0;
       return 0;
@@ -253,7 +254,11 @@ int main(int argc, char *argv[])
          std::cout << "Consistency check failed " << std::endl;
          return 1;
       }
+     
       // get the images pixels
+      
+      // Oops! The following code assumes Pixel Data is uncompressed :-(
+      
       pixels = sqi->GetDataEntry(0x7fe0,0x0010);
       offset = pixels->GetOffset();
       // perform a fseek, on offset length on the 'right' length
@@ -271,7 +276,7 @@ int main(int argc, char *argv[])
 
    std::string NumberOfFrames = gdcm::Util::Format("%d", nbImages); 
 
-   gdcm::File *n = new gdcm::File();
+   gdcm::File *n = gdcm::File::New();
 
    n->InsertEntryString(MediaStSOPinstUID,  0x0002,0x0002);
   // Whe keep default gdcm Transfer Syntax (Explicit VR Little Endian)
@@ -292,7 +297,7 @@ int main(int argc, char *argv[])
    n->InsertEntryString(PixelRepresentation,0x0028,0x0103);
 
    // create the file
-   gdcm::FileHelper *file = new gdcm::FileHelper(n);
+   gdcm::FileHelper *file = gdcm::FileHelper::New(n);
 
    file->SetImageData(PixelArea,lgrImage*nbImages);
    file->SetWriteTypeToDcmExplVR();
@@ -305,7 +310,11 @@ int main(int argc, char *argv[])
    if (!file)
    {
       std::cout <<"Fail to open (write) file:[" << outputFileName << "]" << std::endl;;
+      n->Delete();
+      file->Delete();
       return 1;  
    }
+   n->Delete();
+   file->Delete();
    return 0;
 }