X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Testing%2FTestCopyDicom.cxx;h=62e1a727e9a1a68e0c51a0520786bcdf13132076;hb=2d4135caaf9d8aa9cc41ae562369af518d646e0f;hp=5b35c48bd57c22bf2cc8dc365f98fa28d81a4b01;hpb=f7f4b2e2843f917ac08f9fdc58fc23ca44d8a14d;p=gdcm.git diff --git a/Testing/TestCopyDicom.cxx b/Testing/TestCopyDicom.cxx index 5b35c48b..62e1a727 100644 --- a/Testing/TestCopyDicom.cxx +++ b/Testing/TestCopyDicom.cxx @@ -9,6 +9,8 @@ #ifndef _WIN32 #include //for access, unlink +#else +#include //for _access on Win32 #endif // return true if the file exists @@ -41,7 +43,7 @@ bool RemoveFile(const char* source) // Here we load a gdcmFile and then try to create from scratch a copy of it, // copying field by field the dicom image -int TestCopyDicom(int argc, char* argv[]) +int TestCopyDicom(int , char* []) { int i =0; int retVal = 0; //by default this is an error @@ -67,7 +69,10 @@ int TestCopyDicom(int argc, char* argv[]) gdcmFile *original = new gdcmFile( filename ); gdcmFile *copy = new gdcmFile( output ); - TagDocEntryHT & Ht = original->GetHeader()->GetEntry(); + TagDocEntryHT & Ht = original->GetHeader()->GetEntry(); + + size_t dataSize = original->GetImageDataSize(); + uint8_t* imageData = original->GetImageData(); //First of all copy the header field by field @@ -84,33 +89,30 @@ int TestCopyDicom(int argc, char* argv[]) if ( gdcmBinEntry* b = dynamic_cast(d) ) { copy->GetHeader()->ReplaceOrCreateByNumber( - b->GetVoidArea(), + b->GetBinArea(), b->GetLength(), b->GetGroup(), b->GetElement(), b->GetVR() ); - } - else if ( gdcmValEntry* v = dynamic_cast(d) ) - { - copy->GetHeader()->ReplaceOrCreateByNumber( + } + else if ( gdcmValEntry* v = dynamic_cast(d) ) + { + copy->GetHeader()->ReplaceOrCreateByNumber( v->GetValue(), v->GetGroup(), v->GetElement(), v->GetVR() ); - } - else - { + } + else + { // We skip pb of SQ recursive exploration //std::cout << "Skipped Sequence " // << "------------- " << d->GetVR() << " "<< std::hex // << d->GetGroup() << " " << d->GetElement() // << std::endl; - } + } } - size_t dataSize = original->GetImageDataSize(); - void *imageData = original->GetImageData(); - copy->SetImageData(imageData, dataSize); original->GetHeader()->SetImageDataSize(dataSize);