X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Testing%2FTestWriteSimple.cxx;h=3c0dbafd6a00afa8046f38a916f90745a72ac07e;hb=f2a52d001685df67875981cf460a9c2a078d62a4;hp=c5f4c39353e88dc27876fe15844f5d526d014d47;hpb=6b51b22366f878e1050c75a6ebb755bd2ff365c7;p=gdcm.git diff --git a/Testing/TestWriteSimple.cxx b/Testing/TestWriteSimple.cxx index c5f4c393..3c0dbafd 100644 --- a/Testing/TestWriteSimple.cxx +++ b/Testing/TestWriteSimple.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestWriteSimple.cxx,v $ Language: C++ - Date: $Date: 2005/10/25 14:52:31 $ - Version: $Revision: 1.42 $ + Date: $Date: 2005/10/28 13:16:48 $ + Version: $Revision: 1.46 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -45,60 +45,63 @@ typedef struct } Image; Image Images [] = { - {256, 256, 1, 1, 8, 8, 0, 'a'}, - {256, 256, 1, 1, 8, 8, 0, 'e'}, - {256, 256, 1, 1, 8, 8, 0, 'i'}, - - {512, 256, 1, 1, 8, 8, 0, 'a'}, - {512, 256, 1, 1, 8, 8, 0, 'e'}, - {512, 256, 1, 1, 8, 8, 0, 'i'}, - - {256, 512, 1, 1, 8, 8, 0, 'a'}, - {256, 512, 1, 1, 8, 8, 0, 'e'}, - {256, 512, 1, 1, 8, 8, 0, 'i'}, - - {256, 512, 1, 1, 16, 16, 0, 'a'}, - {256, 512, 1, 1, 16, 16, 0, 'e'}, - {256, 512, 1, 1, 16, 16, 0, 'i'}, - {256, 512, 1, 1, 16, 16, 0, 'a'}, - {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'}, - - {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'}, + + {128, 128, 1, 1, 8, 8, 0, 'e'}, + {256, 128, 1, 1, 8, 8, 0, 'e'}, + {128, 128, 1, 1, 16, 16, 0, 'e'}, + {128, 256, 1, 1, 16, 16, 0, 'e'}, + + {128, 128, 1, 1, 8, 8, 0, 'i'}, + {256, 128, 1, 1, 8, 8, 0, 'i'}, + {256, 128, 1, 1, 8, 8, 0, 'a'}, + {128, 128, 1, 1, 8, 8, 0, 'a'}, + + {128, 256, 1, 1, 8, 8, 0, 'e'}, + {128, 256, 1, 1, 8, 8, 0, 'i'}, + {128, 256, 1, 1, 8, 8, 0, 'a'}, + + {128, 256, 1, 1, 16, 16, 0, 'i'}, + {128, 256, 1, 1, 16, 16, 0, 'i'}, + {128, 256, 1, 1, 16, 16, 0, 'a'}, + {128, 256, 1, 1, 16, 16, 0, 'a'}, + + {256, 128, 10, 1, 8, 8, 0, 'e'}, + {256, 128, 10, 3, 8, 8, 0, 'e'}, + {256, 128, 10, 3, 8, 8, 0, 'i'}, + {256, 128, 10, 1, 8, 8, 0, 'i'}, + {256, 128, 10, 1, 8, 8, 0, 'a'}, + {256, 128, 10, 3, 8, 8, 0, 'a'}, + + {128, 128, 1, 1, 8, 8, 1, 'e'}, + {128, 128, 1, 1, 8, 8, 1, 'i'}, + {128, 128, 1, 1, 8, 8, 1, 'a'}, + + {256, 128, 1, 1, 8, 8, 1, 'e'}, + {256, 128, 1, 1, 8, 8, 1, 'i'}, + {256, 128, 1, 1, 8, 8, 1, 'a'}, + + {128, 256, 1, 1, 8, 8, 1, 'a'}, + {128, 256, 1, 1, 8, 8, 1, 'e'}, + {128, 256, 1, 1, 8, 8, 1, 'i'}, + + {128, 256, 1, 1, 16, 16, 1, 'e'}, + {128, 256, 1, 1, 16, 16, 1, 'e'}, + {128, 256, 1, 1, 16, 16, 1, 'i'}, + {128, 256, 1, 1, 16, 16, 1, 'i'}, + {128, 256, 1, 1, 16, 16, 1, 'a'}, + {128, 256, 1, 1, 16, 16, 1, 'a'}, + + {256, 128, 10, 1, 8, 8, 1, 'e'}, + {256, 128, 10, 1, 8, 8, 1, 'i'}, + {256, 128, 10, 1, 8, 8, 1, 'a'}, + + {256, 128, 10, 3, 8, 8, 1, 'e'}, + {256, 128, 10, 3, 8, 8, 1, 'i'}, + {256, 128, 10, 3, 8, 8, 1, 'a'}, {0, 0, 1, 1, 8, 8, 0, 'i'} // to find the end }; + const unsigned int MAX_NUMBER_OF_DIFFERENCE = 10; int WriteSimple(Image &img) @@ -107,10 +110,13 @@ int WriteSimple(Image &img) fileName.str(""); fileName << "TestWriteSimple"; -// Step 1 : Create the header of the image +// Step 1 : Create an empty FileHelper std::cout << " 1..."; - gdcm::File *fileToBuild = gdcm::File::New(); + gdcm::FileHelper *fileH = gdcm::FileHelper::New(); + + // Get the (empty) image header. + gdcm::File *fileToBuild = fileH->GetFile(); std::ostringstream str; // Set the image size @@ -165,7 +171,6 @@ int WriteSimple(Image &img) } std::cout << "[" << fileName.str() << "]..."; - // Set the samples per pixel str.str(""); str << img.components; @@ -202,9 +207,8 @@ int WriteSimple(Image &img) } } -// Step 3 : Create the file of the image +// Step 3 : Set the image Pixel Data std::cout << "3..."; - gdcm::FileHelper *fileH = gdcm::FileHelper::New(fileToBuild); fileH->SetImageData(imageData,size); // Step 4 : Set the writting mode and write the image @@ -230,7 +234,6 @@ int WriteSimple(Image &img) << " Write mode '"<Delete(); - fileToBuild->Delete(); delete[] imageData; return 1; } @@ -241,7 +244,7 @@ int WriteSimple(Image &img) << " File is unwrittable\n"; fileH->Delete(); - fileToBuild->Delete(); + delete[] imageData; return 1; } @@ -360,7 +363,6 @@ int WriteSimple(Image &img) std::cout << "OK" << std::endl; - fileToBuild->Delete(); fileH->Delete(); reread->Delete(); delete[] imageData; @@ -378,7 +380,7 @@ int TestWriteSimple(int argc, char *argv[]) return 1; } - //gdcm::Debug::DebugOn(); + gdcm::Debug::DebugOn(); int ret=0; int i=0;