X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Example%2FTestReadWriteReadCompare.cxx;h=2eab99008bce0fd40672377233faf2974d041cab;hb=8a9ab161e2643bf1406660e2fbbf5caf8f915137;hp=5ea15b8ca7c9775cf2e0baf8dae63e6677c39a29;hpb=770d6ef4630d6243dba1813a75c3dc2f62668a8c;p=gdcm.git diff --git a/Example/TestReadWriteReadCompare.cxx b/Example/TestReadWriteReadCompare.cxx index 5ea15b8c..2eab9900 100644 --- a/Example/TestReadWriteReadCompare.cxx +++ b/Example/TestReadWriteReadCompare.cxx @@ -1,3 +1,20 @@ +/*========================================================================= + + Program: gdcm + Module: $RCSfile: TestReadWriteReadCompare.cxx,v $ + Language: C++ + Date: $Date: 2004/11/16 04:26:18 $ + 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 + 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" @@ -6,10 +23,10 @@ int main(int argc, char* argv[]) { - if (argc) + if (argc<2) { std::cerr << "Test::TestReadWriteReadCompare: Usage: " << argv[0] - << " (no arguments needed)." << std::endl; + << " fileToCheck.dcm " << std::endl; } std::cout<< "Test::TestReadWriteReadCompare: description " << std::endl; @@ -28,18 +45,19 @@ int main(int argc, char* argv[]) << "images " << std::endl << " match (as expanded by gdcm)." << std::endl; - int i = 0; - while( gdcmDataImages[i] != 0 ) + //int i = 0; + //while( gdcmDataImages[i] != 0 ) { std::string filename = GDCM_DATA_ROOT; filename += "/"; - filename += gdcmDataImages[i++]; + //filename += gdcmDataImages[i++]; + filename +=argv[1]; std::cout << " Testing: " << filename << std::endl; - //////////////// Step 1 (see above description): + //////////////// Step 1 (see above description): - gdcmHeader *header = new gdcmHeader( filename ); + gdcm::Header *header = new gdcm::Header( filename ); if( !header->IsReadable() ) { std::cerr << "Test::TestReadWriteReadCompare: Image not gdcm compatible:" @@ -51,9 +69,9 @@ int main(int argc, char* argv[]) //////////////// Step 2: - gdcmFile* file = new gdcmFile( header ); + gdcm::File* file = new gdcm::File( header ); int dataSize = file->GetImageDataSize(); - void* imageData = file->GetImageData(); //EXTREMELY IMPORTANT + uint8_t* imageData = file->GetImageData(); //EXTREMELY IMPORTANT // Sure, it is : It's up to the user to decide if he wants to // GetImageData or if he wants to GetImageDataRaw // (even if we do it by setting a flag, he will have to decide) @@ -81,7 +99,7 @@ int main(int argc, char* argv[]) //////////////// Step 3: - gdcmFile* reread = new gdcmFile( "TestReadWriteReadCompare.dcm" ); + gdcm::File* reread = new gdcm::File( "TestReadWriteReadCompare.dcm" ); if( !reread->GetHeader()->IsReadable() ) { std::cerr << "Test::TestReadWriteReadCompare: Could not reread image " @@ -94,7 +112,7 @@ int main(int argc, char* argv[]) std::cout << "3..."; // For the next step: int dataSizeWritten = reread->GetImageDataSize(); - void* imageDataWritten = reread->GetImageData(); + uint8_t* imageDataWritten = reread->GetImageData(); //////////////// Step 4: @@ -103,8 +121,6 @@ int main(int argc, char* argv[]) std::cout << std::endl << " Pixel areas lengths differ: " << dataSize << " # " << dataSizeWritten << std::endl; - delete (char*)imageData; - delete (char*)imageDataWritten; delete header; delete file; delete reread; @@ -116,8 +132,6 @@ int main(int argc, char* argv[]) (void)res; std::cout << std::endl << " Pixel differ (as expanded in memory)." << std::endl; - delete (char*)imageData; - delete (char*)imageDataWritten; delete header; delete file; delete reread; @@ -126,8 +140,6 @@ int main(int argc, char* argv[]) std::cout << "4...OK." << std::endl ; //////////////// Clean up: - delete (char*)imageData; - delete (char*)imageDataWritten; delete header; delete file; delete reread;