]> Creatis software - gdcm.git/blobdiff - Testing/TestReadWriteReadCompare.cxx
* src/gdcmDocument.cxx : fix bug... test if the fp is opened to use it
[gdcm.git] / Testing / TestReadWriteReadCompare.cxx
index 66115b8e2d0feb80c1e38043c3f7319dc29fa95c..b5359ba8990b8b00f27ae8afcff8bd76687ac4c7 100644 (file)
@@ -1,3 +1,20 @@
+/*=========================================================================
+                                                                                
+  Program:   gdcm
+  Module:    $RCSfile: TestReadWriteReadCompare.cxx,v $
+  Language:  C++
+  Date:      $Date: 2004/11/25 10:24:34 $
+  Version:   $Revision: 1.16 $
+                                                                                
+  Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+  l'Image). All rights reserved. See Doc/License.txt or
+  http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
+                                                                                
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notices for more information.
+                                                                                
+=========================================================================*/
 #include "gdcmHeader.h"
 #include "gdcmFile.h"
 
@@ -18,7 +35,7 @@ int CompareInternal(std::string const & filename, std::string const & output)
       delete header;
       return 1;
    }
-   std::cout << "           step 1 ...";
+   std::cout << "           step 1...";
 
    //////////////// Step 2:
 
@@ -47,6 +64,7 @@ int CompareInternal(std::string const & filename, std::string const & output)
    
    file->SetImageData(imageData, dataSize);
    
+   file->SetWriteModeToRGB();
    file->WriteDcmExplVR( output );
    std::cout << "2...";
  
@@ -55,7 +73,8 @@ int CompareInternal(std::string const & filename, std::string const & output)
    gdcm::File* reread = new gdcm::File( output );
    if( !reread->GetHeader()->IsReadable() )
    {
-     std::cerr << "Test::TestReadWriteReadCompare: Could not reread image "
+     std::cerr << "Failed" << std::endl
+               << "Test::TestReadWriteReadCompare: Could not reread image "
                << "written:" << filename << std::endl;
      delete header;
      delete file;
@@ -65,17 +84,15 @@ int CompareInternal(std::string const & filename, std::string const & output)
    std::cout << "3...";
    // For the next step:
    int    dataSizeWritten = reread->GetImageDataSize();
-   void* imageDataWritten = reread->GetImageData();
+   uint8_t* imageDataWritten = reread->GetImageData();
 
    //////////////// Step 4:
 
    if (dataSize != dataSizeWritten)
    {
-      std::cout << std::endl
+      std::cout << "Failed" << std::endl
          << "        Pixel areas lengths differ: "
          << dataSize << " # " << dataSizeWritten << std::endl;
-      delete[] (char*)imageData;
-      delete[] (char*)imageDataWritten;
       delete header;
       delete file;
       delete reread;
@@ -85,10 +102,8 @@ int CompareInternal(std::string const & filename, std::string const & output)
    if (int res = memcmp(imageData, imageDataWritten, dataSize) !=0)
    {
       (void)res;
-      std::cout << std::endl
+      std::cout << "Failed" << std::endl
          << "        Pixel differ (as expanded in memory)." << std::endl;
-      delete[] (char*)imageData;
-      delete[] (char*)imageDataWritten;
       delete header;
       delete file;
       delete reread;
@@ -97,8 +112,6 @@ int CompareInternal(std::string const & filename, std::string const & output)
    std::cout << "4...OK." << std::endl ;
 
    //////////////// Clean up:
-   delete[] (char*)imageData;
-   delete[] (char*)imageDataWritten;
    delete header;
    delete file;
    delete reread;