+ std::cout << "OK." << std::endl ;
+
+ delete original;
+ delete copy;
+
+ return 0;
+}
+
+// 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[])
+{
+ if ( argc == 3 )
+ {
+ // The test is specified a specific filename, use it instead of looping
+ // over all images
+ const std::string input = argv[1];
+ const std::string reference = argv[2];
+ return CopyDicom( input, reference );
+ }
+ else if ( argc > 3 || argc == 2 )
+ {
+ std::cout << " Usage: " << argv[0]
+ << " (no arguments needed)." << std::endl;
+ std::cout << "or Usage: " << argv[0]
+ << " filename.dcm reference.dcm" << std::endl;
+ return 1;
+ }
+ // else other cases:
+
+ std::cout << " Description (Test::TestCopyDicom): "
+ << std::endl;
+ std::cout << " For all images in gdcmData (and not blacklisted in "
+ "Test/CMakeLists.txt)"
+ << std::endl;
+ std::cout << " apply the following to each filename.xxx: "
+ << std::endl;
+ std::cout << " step 1: parse the image (as gdcmHeader) and call"
+ << " IsReadable(). After that, call GetImageData() and "
+ << "GetImageDataSize() "
+ << std::endl;
+ std::cout << " step 2: create a copy of the readed file and the new"
+ << " pixel datas are set to the copy"
+ << std::endl;
+ std::cout << " step 3: write the copy of the image"
+ << std::endl;
+ std::cout << " step 4: read the copy and call IsReadable()"
+ << std::endl;
+ std::cout << " step 5: compare (in memory with memcmp) that the two "
+ << "images " << std::endl
+ << " match (as expanded by gdcm)." << std::endl;
+ std::cout << std::endl;
+
+ int i =0;
+ int retVal = 0; //by default this is an error
+ while( gdcmDataImages[i] != 0 )
+ {
+ std::string filename = GDCM_DATA_ROOT;
+ filename += "/"; //doh!
+ filename += gdcmDataImages[i];
+
+// std::string output = "../Testing/Temporary/output.dcm";
+ std::string output = "output.dcm";
+
+ if( CopyDicom( filename, output ) != 0 )
+ {
+ retVal++;
+ }
+