X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Testing%2FTestCopyRescaleDicom.cxx;h=6616afa17340987ce594af802f771f2a3686c5f5;hb=d00078b5e19310b379c8339fa8fe38362e8ca392;hp=6a1d1521bfdf511e7353a8153db71739e61fad55;hpb=412cf9757709333001ae81f5f4079e53c62840c7;p=gdcm.git diff --git a/Testing/TestCopyRescaleDicom.cxx b/Testing/TestCopyRescaleDicom.cxx index 6a1d1521..6616afa1 100644 --- a/Testing/TestCopyRescaleDicom.cxx +++ b/Testing/TestCopyRescaleDicom.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestCopyRescaleDicom.cxx,v $ Language: C++ - Date: $Date: 2004/12/07 18:16:40 $ - Version: $Revision: 1.2 $ + Date: $Date: 2005/01/20 16:16:59 $ + 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 @@ -16,7 +16,7 @@ =========================================================================*/ #include "gdcmHeader.h" -#include "gdcmFile.h" +#include "gdcmFileHelper.h" #include "gdcmValEntry.h" #include "gdcmBinEntry.h" @@ -56,15 +56,13 @@ int CopyRescaleDicom(std::string const & filename, //////////////// Step 2: std::cout << "2..."; - originalH->Initialize(); - gdcm::DocEntry* d = originalH->GetNextEntry(); - // Copy of the header content + gdcm::DocEntry* d = originalH->GetFirstEntry(); while(d) { if ( gdcm::BinEntry* b = dynamic_cast(d) ) { - copyH->ReplaceOrCreateByNumber( + copyH->ReplaceOrCreate( b->GetBinArea(), b->GetLength(), b->GetGroup(), @@ -73,7 +71,7 @@ int CopyRescaleDicom(std::string const & filename, } else if ( gdcm::ValEntry* v = dynamic_cast(d) ) { - copyH->ReplaceOrCreateByNumber( + copyH->ReplaceOrCreate( v->GetValue(), v->GetGroup(), v->GetElement(), @@ -87,23 +85,22 @@ int CopyRescaleDicom(std::string const & filename, d=originalH->GetNextEntry(); } - gdcm::File *original = new gdcm::File( originalH ); - gdcm::File *copy = new gdcm::File( copyH ); + gdcm::FileHelper *original = new gdcm::FileHelper( originalH ); + gdcm::FileHelper *copy = new gdcm::FileHelper( copyH ); size_t dataSize = original->GetImageDataSize(); - uint8_t* imageData = original->GetImageData(); size_t rescaleSize; uint8_t *rescaleImage; - const std::string & bitsStored = originalH->GetEntryByNumber(0x0028,0x0101); + const std::string & bitsStored = originalH->GetEntry(0x0028,0x0101); if( bitsStored == "16" ) { std::cout << "Rescale..."; - copyH->ReplaceOrCreateByNumber( "8", 0x0028, 0x0100); // BitsAllocated - copyH->ReplaceOrCreateByNumber( "8", 0x0028, 0x0101); // BitsStored - copyH->ReplaceOrCreateByNumber( "7", 0x0028, 0x0102); // HighBit - copyH->ReplaceOrCreateByNumber( "0", 0x0028, 0x0103); //Pixel Representation + copyH->ReplaceOrCreate( "8", 0x0028, 0x0100); // BitsAllocated + copyH->ReplaceOrCreate( "8", 0x0028, 0x0101); // BitsStored + copyH->ReplaceOrCreate( "7", 0x0028, 0x0102); // HighBit + copyH->ReplaceOrCreate( "0", 0x0028, 0x0103); //Pixel Representation // We assume the value were from 0 to uint16_t max rescaleSize = dataSize / 2; @@ -147,7 +144,7 @@ int CopyRescaleDicom(std::string const & filename, //////////////// Step 4: std::cout << "4..."; - copy = new gdcm::File( output ); + copy = new gdcm::FileHelper( output ); //Is the file written still gdcm parsable ? if ( !copy->GetHeader()->IsReadable() )