1 /*=========================================================================
4 Module: $RCSfile: BatchUncompress.cxx,v $
6 Date: $Date: 2007/06/21 15:06:12 $
7 Version: $Revision: 1.4 $
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 // Well ... ReWrite.cxx does the same thing
29 #include "gdcmFileHelper.h"
30 #include "gdcmDocument.h"
32 int main(int argc, char *argv[])
36 std::cerr << "Usage :" << std::endl << argv[0] <<
37 " InputHeader OutputDicom" << std::endl;
41 const char *inputfilename = argv[1];
42 const char *outputfilename = argv[2];
44 GDCM_NAME_SPACE::File *input = new GDCM_NAME_SPACE::File( );
45 input->SetFileName( inputfilename );
46 // input->SetLoadMode(loadMode);
48 if ( input->IsReadable() )
50 GDCM_NAME_SPACE::FileHelper *output = new GDCM_NAME_SPACE::FileHelper( input );
52 output->GetImageData(); //EXTREMELY IMPORTANT
53 //Otherwise ReadPixel == -1 -> the dicom writing fails completely
54 int dataSize = output->GetImageDataSize();
55 uint8_t *imageData = output->GetImageData();
57 output->SetImageData( imageData, dataSize);
58 // lossy compression would be a pixel modification.
59 // uncompress is *not*
60 fh->SetContentType(GDCM_NAME_SPACE::UNMODIFIED_PIXELS_IMAGE);
61 output->WriteDcmExplVR( outputfilename );