X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Testing%2FTestReadWriteReadCompare.cxx;h=3de35a99cdacbe1db14bc9c255d3d97711adc118;hb=2b0e408f3a5b86ef701f9da83d3dda0400facc67;hp=655e12821407ab5015d29107bf073f8ec79f9572;hpb=a62b5eb4984601395f2e1296045bacd693ef860d;p=gdcm.git diff --git a/Testing/TestReadWriteReadCompare.cxx b/Testing/TestReadWriteReadCompare.cxx index 655e1282..3de35a99 100644 --- a/Testing/TestReadWriteReadCompare.cxx +++ b/Testing/TestReadWriteReadCompare.cxx @@ -1,19 +1,19 @@ /*========================================================================= - + Program: gdcm Module: $RCSfile: TestReadWriteReadCompare.cxx,v $ Language: C++ - Date: $Date: 2007/06/21 14:59:06 $ - Version: $Revision: 1.29 $ - + Date: $Date: 2007/09/04 13:02:45 $ + Version: $Revision: 1.33 $ + 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 "gdcmFile.h" #include "gdcmFileHelper.h" @@ -40,21 +40,23 @@ int CompareInternal(std::string const &filename, std::string const &output) return 1; } std::cout << " step 1..."; - + std::cout << "--- End of Reading \n"; + //////////////// Step 2: GDCM_NAME_SPACE::FileHelper *filehelper = GDCM_NAME_SPACE::FileHelper::New( file ); int dataSize = filehelper->GetImageDataSize(); uint8_t *imageData = filehelper->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) + // (even if we do it by setting a flag, *he* will have to decide) //filehelper->SetImageData(imageData, dataSize); - + filehelper->SetWriteModeToRGB(); filehelper->WriteDcmExplVR( output ); std::cout << "2..."; - + std::cout << "--- End of Writting \n"; + //////////////// Step 3: GDCM_NAME_SPACE::File *fileout = GDCM_NAME_SPACE::File::New(); fileout->SetFileName( output ); @@ -71,14 +73,15 @@ int CompareInternal(std::string const &filename, std::string const &output) fileout->Delete(); return 1; } - + std::cout << "--- End of Re-Reading \n"; GDCM_NAME_SPACE::FileHelper *reread = GDCM_NAME_SPACE::FileHelper::New( fileout ); std::cout << "3..."; // For the next step: int dataSizeWritten = reread->GetImageDataSize(); uint8_t *imageDataWritten = reread->GetImageData(); - + std::cout << "--- End of GetImageData \n"; + //////////////// Step 4: // Test the image size if (file->GetXSize() != reread->GetFile()->GetXSize() || @@ -87,11 +90,11 @@ int CompareInternal(std::string const &filename, std::string const &output) { std::cout << "Failed" << std::endl << " X Size differs: " - << "X: " << file->GetXSize() << " # " + << "X: " << file->GetXSize() << " # " << reread->GetFile()->GetXSize() << " | " - << "Y: " << file->GetYSize() << " # " + << "Y: " << file->GetYSize() << " # " << reread->GetFile()->GetYSize() << " | " - << "Z: " << file->GetZSize() << " # " + << "Z: " << file->GetZSize() << " # " << reread->GetFile()->GetZSize() << std::endl; file->Delete(); filehelper->Delete(); @@ -101,7 +104,11 @@ int CompareInternal(std::string const &filename, std::string const &output) } // Test the data size - if (dataSize != dataSizeWritten) + // beware of odd length Pixel Element! + int dataSizeFixed = dataSize + dataSize%2; + int dataSizeWrittenFixed = dataSizeWritten + dataSizeWritten%2; + + if (dataSizeFixed != dataSizeWrittenFixed) { std::cout << "Failed" << std::endl << " Pixel areas lengths differ: "