1 /*=========================================================================
4 Module: $RCSfile: BatchUncompress.cxx,v $
6 Date: $Date: 2005/12/12 23:46:52 $
7 Version: $Revision: 1.1 $
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 =========================================================================*/
20 * http://groups.google.com/group/comp.protocols.dicom/browse_thread/thread/2c70859b49122249/3c292c6acc5603ac
21 * For the origin of this example. I think most people are looking for this kind of batch anyway.
22 * Someone at some point could update it to have more option, like not copying the private tags,
26 #include "gdcmFileHelper.h"
27 #include "gdcmDocument.h"
29 int main(int argc, char *argv[])
33 std::cerr << "Usage :" << std::endl << argv[0] <<
34 " InputHeader OutputDicom" << std::endl;
38 const char *inputfilename = argv[1];
39 const char *outputfilename = argv[2];
41 gdcm::File *input = new gdcm::File( );
42 input->SetFileName( inputfilename );
43 // input->SetLoadMode(loadMode);
45 if ( input->IsReadable() )
47 gdcm::FileHelper *output = new gdcm::FileHelper( input );
49 output->GetImageData(); //EXTREMELY IMPORTANT
50 //Otherwise ReadPixel == -1 -> the dicom writing fails completely
51 int dataSize = output->GetImageDataSize();
52 uint8_t *imageData = output->GetImageData();
54 output->SetImageData( imageData, dataSize);
55 output->WriteDcmExplVR( outputfilename );