X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Example%2FWriteRead.cxx;h=8ff10006dfe3329750b7aa98122224d073e81747;hb=f711022dedd779e5e58e649af8c440a4a58bdba1;hp=ac57e18f0c9078c49d5197d4f2b5e5ef67848a99;hpb=3afc179392ebebe610f7685bc8895b690c2a66aa;p=gdcm.git diff --git a/Example/WriteRead.cxx b/Example/WriteRead.cxx index ac57e18f..8ff10006 100644 --- a/Example/WriteRead.cxx +++ b/Example/WriteRead.cxx @@ -1,15 +1,33 @@ +/*========================================================================= + + Program: gdcm + Module: $RCSfile: WriteRead.cxx,v $ + Language: C++ + Date: $Date: 2005/02/02 10:06:32 $ + Version: $Revision: 1.13 $ + + 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" + #include -#include -#include "gdcm.h" -int main(int argc, char* argv[]) +int main(int argc, char *argv[]) { - std::string toto; - char zozo[200]; - - gdcm::Header* e1, *e2; - gdcm::File * f1, *f2; + std::string fileNameToWrite; + gdcm::File *e1; + gdcm::File *e2; + gdcm::FileHelper *f1; + gdcm::FileHelper *f2; uint8_t* imageData, *imageData2; int dataSize, dataSize2; @@ -19,38 +37,38 @@ int main(int argc, char* argv[]) return 1; } - toto = argv[1]; + std::string fileName = argv[1]; // --------------------- we read the input image std::cout << argv[1] << std::endl; - e1 = new gdcm::Header( toto ); + e1 = new gdcm::File( fileName ); if (!e1->IsReadable()) { - std::cerr << "Sorry, " << toto <<" not a Readable DICOM / ACR File" + std::cerr << "Sorry, " << fileName <<" not a Readable DICOM / ACR File" <GetImageData(); dataSize = f1->GetImageDataSize(); // --------------------- we write it as an Explicit VR DICOM file - sprintf(zozo, "temp.XDCM" ); + fileNameToWrite = "temp.XDCM"; std::cout << "WriteDCM Explicit VR" << std::endl; - f1->WriteDcmExplVR(zozo); + f1->WriteDcmExplVR(fileNameToWrite); // --------------------- we read the written image - e2 = new gdcm::Header( zozo ); + e2 = new gdcm::File( fileNameToWrite ); if (!e2->IsReadable()) { - std::cerr << "Sorry, " << zozo << " not a Readable DICOM / ACR File" + std::cerr << "Sorry, " << fileNameToWrite << " not a Readable DICOM / ACR File" <GetImageData(); dataSize2 = f2->GetImageDataSize(); @@ -60,14 +78,14 @@ int main(int argc, char* argv[]) std::cout << " ----------------------------------------- " << "Bad shot! Lengthes are different : " << dataSize << " # " << dataSize2 - << " for file : " << toto << std::endl; + << " for file : " << fileName << std::endl; return 0; } if (int res=memcmp(imageData,imageData2,dataSize) !=0) { std::cout << " ----------------------------------------- " << "Bad shot! Pixels are different : " - << " for file : " << toto << std::endl; + << " for file : " << fileName << std::endl; std::cout << "memcmp(imageData,imageData2,dataSize) = " << res << std::endl; return 1; }