1 /*=========================================================================
4 Module: $RCSfile: PrintFile.cxx,v $
6 Date: $Date: 2005/05/04 07:29:17 $
7 Version: $Revision: 1.36 $
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 "gdcmDebug.h"
20 #include "gdcmFileHelper.h"
24 int main(int argc, char *argv[])
32 std::cout << " usage : PrintFile fileName printLevel debug "
33 << "short (=NOSEQ + NOSHADOW)"
38 e1 = new gdcm::File();
46 gdcm::Debug::DebugOn();
50 e1->SetLoadMode(NO_SEQ | NO_SHADOW);
52 // gdcm::File::IsReadable() is no usable here, because we deal with
53 // any kind of gdcm-Parsable *document*
54 // not only gdcm::File (as opposed to gdcm::DicomDir)
55 res = e1->Load( fileName.c_str() );
62 f1 = new gdcm::FileHelper(e1);
64 if (argc > 2) // keep it here (f1 needs to be constructed !)
66 int level = atoi(argv[2]);
67 f1->SetPrintLevel(level);
72 std::cout << "\n\n" << std::endl;
74 std::cout <<std::endl;
75 std::cout <<" dataSize " << f1->GetImageDataSize() << std::endl;
76 std::cout <<" dataSizeRaw " << f1->GetImageDataRawSize() << std::endl;
78 int nX,nY,nZ,sPP,planarConfig;
79 std::string pixelType;
83 std::cout << " DIMX=" << nX << " DIMY=" << nY << " DIMZ=" << nZ << std::endl;
85 pixelType = e1->GetPixelType();
86 sPP = e1->GetSamplesPerPixel();
87 planarConfig = e1->GetPlanarConfiguration();
89 std::cout << " pixelType= [" << pixelType
90 << "] SamplesPerPixel= [" << sPP
91 << "] PlanarConfiguration= [" << planarConfig
93 << " PhotometricInterpretation= ["
94 << e1->GetEntryValue(0x0028,0x0004)
97 int numberOfScalarComponents=e1->GetNumberOfScalarComponents();
98 std::cout << " NumberOfScalarComponents = " << numberOfScalarComponents <<std::endl
99 << " LUT = " << (e1->HasLUT() ? "TRUE" : "FALSE")
103 if ( e1->GetEntryValue(0x0002,0x0010) == gdcm::GDCM_NOTLOADED )
105 std::cout << "Transfer Syntax not loaded. " << std::endl
106 << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE"
111 std::string transferSyntaxName = e1->GetTransferSyntaxName();
112 std::cout << " TransferSyntaxName= [" << transferSyntaxName << "]" << std::endl;
113 std::cout << " SwapCode= " << e1->GetSwapCode() << std::endl;
116 std::cout <<std::endl<<fileName<<" is Readable"<<std::endl;
118 std::cout <<std::endl<<fileName<<" is NOT Readable"<<std::endl;
119 std::cout<<std::flush;