1 /*=========================================================================
4 Module: $RCSfile: Write.cxx,v $
6 Date: $Date: 2005/02/02 10:06:32 $
7 Version: $Revision: 1.19 $
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"
23 int main(int argc, char *argv[])
25 std::string FileNameToWrite;
34 std::cerr << "usage: " << std::endl
35 << argv[0] << " fileName writtingMode "
37 << "(a : ACR, d : DICOM Implicit VR,"
38 << " x : DICOM Explicit VR, r : RAW)"
43 if (0) { // Just to keep the code for further use
44 std::cout <<std::endl << "-------- Test gdcmFile ------" <<std::endl;
45 e1 = new gdcmFileHelper(argv[1]);
46 if (!f1->GetFile()->IsReadable()) {
47 std::cout << "Sorry, not a DICOM / ACR File" <<std::endl;
50 std::cout << std::endl << "----------------------> after new gdcmFile"
53 std::cout <<std::endl <<"---------------------------------------"
58 std::cout << std::endl
59 << "--------------------- file :" << argv[1]
62 std::string FileName = argv[1];
64 e1 = new gdcm::File( FileName.c_str() );
65 if (!e1->IsReadable()) {
66 std::cerr << "Sorry, not a Readable DICOM / ACR File" <<std::endl;
71 f1 = new gdcm::FileHelper(e1);
74 dataSize = f1->GetImageDataSize();
75 std::cout <<std::endl <<" dataSize " << dataSize << std::endl;
76 int nX,nY,nZ,sPP,planarConfig;
77 std::string pixelType, transferSyntaxName;
81 std::cout << " DIMX=" << nX << " DIMY=" << nY << " DIMZ=" << nZ << std::endl;
83 pixelType = e1->GetPixelType();
84 sPP = e1->GetSamplesPerPixel();
85 planarConfig = e1->GetPlanarConfiguration();
87 std::cout << " pixelType=" << pixelType
88 << " SampleserPixel=" << sPP
89 << " PlanarConfiguration=" << planarConfig
90 << " PhotometricInterpretation="
91 << e1->GetEntryValue(0x0028,0x0004)
94 int numberOfScalarComponents=e1->GetNumberOfScalarComponents();
95 std::cout << "NumberOfScalarComponents " << numberOfScalarComponents <<std::endl;
96 transferSyntaxName = e1->GetTransferSyntaxName();
97 std::cout << " TransferSyntaxName= [" << transferSyntaxName << "]" << std::endl;
99 /* if ( transferSyntaxName != "Implicit VR - Little Endian"
100 && transferSyntaxName != "Explicit VR - Little Endian"
101 && transferSyntaxName != "Deflated Explicit VR - Little Endian"
102 && transferSyntaxName != "Explicit VR - Big Endian"
103 && transferSyntaxName != "Uncompressed ACR-NEMA" ) {
104 std::cout << std::endl << "==========================================="
106 f1->GetPixelReadConverter()->Print();
107 std::cout << std::endl << "==========================================="
110 imageData= f1->GetImageData();
111 (void)imageData; // to avoid warnings
116 // ecriture d'un fichier ACR
117 // à partir d'un dcmFile correct.
119 FileNameToWrite = FileName + ".ACR";
120 std::cout << "WriteACR" << std::endl;
121 f1->WriteAcr(FileNameToWrite);
125 // ecriture d'un fichier DICOM Implicit VR
126 // à partir d'un dcmFile correct.
128 FileNameToWrite = FileName + ".DCM";
129 std::cout << "WriteDCM Implicit VR" << std::endl;
130 f1->WriteDcmImplVR(FileNameToWrite);
134 // ecriture d'un fichier DICOM Explicit VR
135 // à partir d'un dcmFile correct.
137 FileNameToWrite = FileName + ".DCM";
138 std::cout << "WriteDCM Implicit VR" << std::endl;
139 f1->WriteDcmExplVR(FileNameToWrite);
143 // Ecriture d'un Raw File, a afficher avec
144 // affim filein= dimx= dimy= nbit= signe=
146 FileNameToWrite = FileName + ".RAW";
147 std::cout << "WriteRaw" << std::endl;
148 f1->WriteRawData(FileNameToWrite);