1 /*=========================================================================
4 Module: $RCSfile: Write.cxx,v $
6 Date: $Date: 2004/11/16 04:26:18 $
7 Version: $Revision: 1.9 $
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 =========================================================================*/
22 int main(int argc, char* argv[])
30 //gdcmDocument * d; //not used
35 std::cerr << "usage: " << std::endl
36 << argv[0] << " fileName writtingMode "
38 << "(a : ACR, d : DICOM Implicit VR,"
39 << " x : DICOM Explicit VR, r : RAW)"
44 if (0) { // Just to keep the code for further use
45 std::cout <<std::endl << "-------- Test gdcmHeader ------" <<std::endl;
46 e1 = new gdcmHeaderHelper(argv[1]);
47 if (!f1->GetHeader()->IsReadable()) {
48 std::cout << "Sorry, not a DICOM / ACR File" <<std::endl;
51 std::cout << std::endl << "----------------------> after new gdcmHeader"
54 std::cout <<std::endl <<"---------------------------------------"
59 std::cout << std::endl
60 << "--------------------- file :" << argv[1]
65 e1 = new gdcm::Header( toto.c_str() );
66 if (!e1->IsReadable()) {
67 std::cerr << "Sorry, not a Readable DICOM / ACR File" <<std::endl;
72 f1 = new gdcm::File(e1);
75 dataSize = f1->GetImageDataSize();
76 std::cout <<std::endl <<" dataSize " << dataSize << std::endl;
77 int nX,nY,nZ,sPP,planarConfig;
78 std::string pixelType, transferSyntaxName;
82 std::cout << " DIMX=" << nX << " DIMY=" << nY << " DIMZ=" << nZ << std::endl;
84 pixelType = e1->GetPixelType();
85 sPP = e1->GetSamplesPerPixel();
86 planarConfig = e1->GetPlanarConfiguration();
88 std::cout << " pixelType=" << pixelType
89 << " SampleserPixel=" << sPP
90 << " PlanarConfiguration=" << planarConfig
91 << " PhotometricInterpretation="
92 << e1->GetEntryByNumber(0x0028,0x0004)
95 int numberOfScalarComponents=e1->GetNumberOfScalarComponents();
96 std::cout << "NumberOfScalarComponents " << numberOfScalarComponents <<std::endl;
97 transferSyntaxName = e1->GetTransfertSyntaxName();
98 std::cout << " TransferSyntaxName= [" << transferSyntaxName << "]" << std::endl;
100 if ( transferSyntaxName != "Implicit VR - Little Endian"
101 && transferSyntaxName != "Explicit VR - Little Endian"
102 && transferSyntaxName != "Deflated Explicit VR - Little Endian"
103 && transferSyntaxName != "Explicit VR - Big Endian"
104 && transferSyntaxName != "Uncompressed ACR-NEMA" ) {
105 std::cout << std::endl << "==========================================="
107 f1->GetPixelConverter()->Print();
108 std::cout << std::endl << "==========================================="
111 imageData= f1->GetImageData();
112 (void)imageData; // to avoid warnings
114 switch (argv[2][0]) {
116 // ecriture d'un fichier ACR
117 // à partir d'un dcmHeader correct.
119 sprintf(zozo, "%s.ACR", toto.c_str());
120 printf ("WriteACR\n");
125 // ecriture d'un fichier DICOM Implicit VR
126 // à partir d'un dcmHeader correct.
128 sprintf(zozo, "%s.DCM", toto.c_str());
129 printf ("WriteDCM Implicit VR\n");
130 f1->WriteDcmImplVR(zozo);
134 // ecriture d'un fichier DICOM Explicit VR
135 // à partir d'un dcmHeader correct.
137 sprintf(zozo, "%s.XDCM", toto.c_str());
138 std::cout << "WriteDCM Explicit VR" << std::endl;
139 f1->WriteDcmExplVR(zozo);
143 // Ecriture d'un Raw File, a afficher avec
144 // affim filein= dimx= dimy= nbit= signe=
146 sprintf(zozo, "%s.RAW", toto.c_str());
147 std::cout << "WriteRaw" << std::endl;
148 f1->WriteRawData(zozo);