]> Creatis software - gdcm.git/blobdiff - Testing/TestWriteSimple.cxx
Change meaningless name 'TestSequence' (that does NOT tests Sequences) to
[gdcm.git] / Testing / TestWriteSimple.cxx
index 249c5212b4797b649db52aaa9a22e0697eb000ad..d0364ea10f116f38f38c33a2acf685090cd19710 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestWriteSimple.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/02/07 19:17:27 $
-  Version:   $Revision: 1.22 $
+  Date:      $Date: 2005/03/02 16:39:28 $
+  Version:   $Revision: 1.26 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -64,13 +64,39 @@ Image Images [] = {
    {256, 512, 1, 1, 16, 16, 0, 'e'},
    {256, 512, 1, 1, 16, 16, 0, 'i'},
 
-   {512, 256, 10, 1, 8,  8, 0, 'a'},
-   {512, 256, 10, 1, 8,  8, 0, 'e'},
-   {512, 256, 10, 1, 8,  8, 0, 'i'},
-   {512, 256, 10, 3, 8,  8, 0, 'a'},
-   {512, 256, 10, 3, 8,  8, 0, 'e'},
-   {512, 256, 10, 3, 8,  8, 0, 'i'},
-   {0,   0,   1,  1, 8,  8, 0, 'i'} // to find the end
+   {512, 256, 10, 1, 8, 8,  0, 'a'},
+   {512, 256, 10, 1, 8, 8,  0, 'e'},
+   {512, 256, 10, 1, 8, 8,  0, 'i'},
+   {512, 256, 10, 3, 8, 8,  0, 'a'},
+   {512, 256, 10, 3, 8, 8,  0, 'e'},
+   {512, 256, 10, 3, 8, 8,  0, 'i'},
+
+   {256, 256, 1, 1, 8,  8,  1, 'a'},
+   {256, 256, 1, 1, 8,  8,  1, 'e'},
+   {256, 256, 1, 1, 8,  8,  1, 'i'},
+
+   {512, 256, 1, 1, 8,  8,  1, 'a'},
+   {512, 256, 1, 1, 8,  8,  1, 'e'},
+   {512, 256, 1, 1, 8,  8,  1, 'i'},
+
+   {256, 512, 1, 1, 8,  8,  1, 'a'},
+   {256, 512, 1, 1, 8,  8,  1, 'e'},
+   {256, 512, 1, 1, 8,  8,  1, 'i'},
+
+   {256, 512, 1, 1, 16, 16, 1, 'a'},
+   {256, 512, 1, 1, 16, 16, 1, 'e'},
+   {256, 512, 1, 1, 16, 16, 1, 'i'},
+   {256, 512, 1, 1, 16, 16, 1, 'a'},
+   {256, 512, 1, 1, 16, 16, 1, 'e'},
+   {256, 512, 1, 1, 16, 16, 1, 'i'},
+
+   {512, 256, 10, 1, 8, 8,  1, 'a'},
+   {512, 256, 10, 1, 8, 8,  1, 'e'},
+   {512, 256, 10, 1, 8, 8,  1, 'i'},
+   {512, 256, 10, 3, 8, 8,  1, 'a'},
+   {512, 256, 10, 3, 8, 8,  1, 'e'},
+   {512, 256, 10, 3, 8, 8,  1, 'i'},
+   {0,   0,   1,  1, 8, 8,  0, 'i'} // to find the end
 };
 
 int WriteSimple(Image &img)
@@ -103,18 +129,6 @@ int WriteSimple(Image &img)
    str << img.componentSize;
    fileToBuild->InsertValEntry(str.str(),0x0028,0x0100); // Bits Allocated
 
-   /******************************************/
-   /******************************************/
-   // Super duper kludge !!
-   if( img.componentSize == 16 )
-   {
-      // I guess by design user should know that...
-      fileToBuild->InsertBinEntry(0,0, 0x7fe0, 0x0010, "OW");
-   }
-   /******************************************/
-   /******************************************/
-   
-
    str.str("");
    str << img.componentUse;
    fileToBuild->InsertValEntry(str.str(),0x0028,0x0101); // Bits Stored
@@ -167,7 +181,7 @@ int WriteSimple(Image &img)
                {
                   *(tmp+1) = j/256;
                }
-               tmp += img.components/8;
+               tmp += img.componentSize/8;
             }
          }
       }
@@ -223,7 +237,7 @@ int WriteSimple(Image &img)
    if( !reread->GetFile()->IsReadable() )
    {
       std::cerr << "Failed" << std::endl
-                << "Could not reread image written: " << fileName << std::endl;
+                << "Could not read written image : " << fileName << std::endl;
       delete fileToBuild;
       delete file;
       delete reread;
@@ -272,9 +286,8 @@ int WriteSimple(Image &img)
    }
 
    // Test the data's content
-   if (int res = memcmp(imageData, imageDataWritten, size) !=0)
+   if ( memcmp(imageData, imageDataWritten, size) !=0 )
    {
-      (void)res;
       std::cout << "Failed" << std::endl
                 << "        Pixel differ (as expanded in memory)." << std::endl;
       delete fileToBuild;
@@ -305,10 +318,13 @@ int TestWriteSimple(int argc, char *argv[])
       return 1;
    }
 
+  // gdcm::Debug::DebugOn();    
    int ret=0;
    int i=0;
    while( Images[i].sizeX>0 && Images[i].sizeY>0 )
    {
+      std::cout << std::endl << "Test n :" << i << std::endl;
       ret += WriteSimple(Images[i]);
       i++;
    }