1 /*=========================================================================
4 Module: $RCSfile: exPrintWritePrint.cxx,v $
6 Date: $Date: 2007/06/21 15:01:00 $
7 Version: $Revision: 1.6 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
19 #include "gdcmFileHelper.h"
21 int main(int argc, char *argv[])
23 GDCM_NAME_SPACE::File *f;
24 GDCM_NAME_SPACE::FileHelper *fh;
25 std::string fileNameToWrite;
29 std::cout << " This program allows to see at a glance" << std::endl;
30 std::cout << " if the GDCM_NAME_SPACE::File remains unimpaired" << std::endl;
31 std::cout << " after a Write" << std::endl;
32 std::cout << " In a future step, we could move it to" << std::endl;
33 std::cout << " gdcm Testing, for a systematic checking"<< std::endl;
34 std::cout << " of the entire dataset" << std::endl;
35 std::cout << " Later ..." << std::endl;
39 std::cerr << "usage: " << std::endl
40 << argv[0] << " OriginalFileName writtingMode "
42 << " a : ACR, produces a file named OriginalFileName.ACR"
43 << " x : DICOM Explicit VR, produces a file named OriginalFileName.XDCM"
44 << " d : DICOM Implicit VR, produces a file named OriginalFileName.DCM"
45 << " WARNING : bugggggggg on shadow SQ with endianness change !"
46 << " r : RAW, produces a file named OriginalFileName.RAW"
51 std::cout << std::endl
52 << "--------------------- file :" << argv[1]
55 std::string fileName = argv[1];
56 std::string mode = argv[2];
58 f = new GDCM_NAME_SPACE::File( );
59 f->SetLoadMode( GDCM_NAME_SPACE::LD_NOSEQ );
60 f->SetFileName( fileName );
65 std::cerr << "Sorry, not a Readable DICOM / ACR File" <<std::endl;
69 fh = new GDCM_NAME_SPACE::FileHelper(f);
74 imageData= fh->GetImageData();
75 dataSize = fh->GetImageDataSize();
77 fh->SetWriteModeToRGB();
82 // ecriture d'un fichier ACR
83 // à partir d'un dcmFile correct.
85 fileNameToWrite = fileName + ".ACR";
86 std::cout << "WriteACR" << std::endl;
87 fh->WriteAcr(fileNameToWrite);
92 // ecriture d'un fichier DICOM Implicit VR
93 // à partir d'un dcmFile correct.
95 fileNameToWrite = fileName + ".DCM";
96 std::cout << "WriteDCM Implicit VR" << std::endl;
97 fh->WriteDcmImplVR(fileNameToWrite);
101 // ecriture d'un fichier DICOM Explicit VR
102 // à partir d'un dcmFile correct.
104 fileNameToWrite = fileName + ".XDCM";
105 std::cout << "WriteDCM Explicit VR" << std::endl;
106 fh->WriteDcmExplVR(fileNameToWrite);
110 // Ecriture d'un Raw File, a afficher avec
111 // affim filein= dimx= dimy= nbit= signe=
113 fileNameToWrite = fileName + ".RAW";
114 std::cout << "WriteRaw" << std::endl;
115 fh->WriteRawData(fileNameToWrite);
119 std::cout << "-----------------------------------------------------------------"