]> Creatis software - gdcm.git/blobdiff - Testing/TestWriteSimple.cxx
* Testing/TestWriteSimple.cxx : fix bug... sorry
[gdcm.git] / Testing / TestWriteSimple.cxx
index 51d04094fcff7e183de784a3c79f6944f5be99c8..fe79c983ddf3cf7c632ece400997683e00feb15a 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestWriteSimple.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/02/02 10:05:26 $
-  Version:   $Revision: 1.18 $
+  Date:      $Date: 2005/02/07 18:43:38 $
+  Version:   $Revision: 1.21 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -63,7 +63,14 @@ Image Images [] = {
    {256, 512, 1, 1, 16, 16, 0, 'a'},
    {256, 512, 1, 1, 16, 16, 0, 'e'},
    {256, 512, 1, 1, 16, 16, 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'},
+   {0,   0,   1,  1, 8,  8, 0, 'i'} // to find the end
 };
 
 int WriteSimple(Image &img)
@@ -96,6 +103,18 @@ 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
@@ -148,7 +167,7 @@ int WriteSimple(Image &img)
                {
                   *(tmp+1) = j/256;
                }
-               tmp += img.componentSize * img.components/8;
+               tmp += img.components/8;
             }
          }
       }
@@ -203,13 +222,13 @@ int WriteSimple(Image &img)
    gdcm::FileHelper *reread = new gdcm::FileHelper( fileName );
    if( !reread->GetFile()->IsReadable() )
    {
-     std::cerr << "Failed" << std::endl
-               << "Test::TestReadWriteReadCompare: Could not reread image "
-               << "written:" << fileName << std::endl;
-     delete fileToBuild;
-     delete file;
-     delete reread;
-     return 1;
+      std::cerr << "Failed" << std::endl
+                << "Could not reread image written: " << fileName << std::endl;
+      delete fileToBuild;
+      delete file;
+      delete reread;
+      delete[] imageData;
+      return 1;
    }
 
 // Step 6 : Compare to the written image