1 /*=========================================================================
4 Module: $RCSfile: Write.cxx,v $
6 Date: $Date: 2004/12/03 20:16:55 $
7 Version: $Revision: 1.12 $
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 =========================================================================*/
18 #include "gdcmHeader.h"
23 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]
63 std::string toto = 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->GetPixelReadConverter()->Print();
108 std::cout << std::endl << "==========================================="
111 imageData= f1->GetImageData();
112 (void)imageData; // to avoid warnings
117 // ecriture d'un fichier ACR
118 // à partir d'un dcmHeader correct.
120 zozo = toto + ".ACR";
121 std::cout << "WriteACR" << std::endl;
126 // ecriture d'un fichier DICOM Implicit VR
127 // à partir d'un dcmHeader correct.
129 zozo = toto + ".DCM";
130 std::cout << "WriteDCM Implicit VR" << std::endl;
131 f1->WriteDcmImplVR(zozo);
135 // ecriture d'un fichier DICOM Explicit VR
136 // à partir d'un dcmHeader correct.
138 zozo = toto + ".DCM";
139 std::cout << "WriteDCM Implicit VR" << std::endl;
140 f1->WriteDcmExplVR(zozo);
144 // Ecriture d'un Raw File, a afficher avec
145 // affim filein= dimx= dimy= nbit= signe=
147 zozo = toto + ".RAW";
148 std::cout << "WriteRaw" << std::endl;
149 f1->WriteRawData(zozo);