]> Creatis software - gdcm.git/blob - Example/BatchUncompress.cxx
Fix mistypings
[gdcm.git] / Example / BatchUncompress.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: BatchUncompress.cxx,v $
5   Language:  C++
6   Date:      $Date: 2007/06/21 15:06:12 $
7   Version:   $Revision: 1.4 $
8                                                                                 
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.
12                                                                                 
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.
16                                                                                 
17 =========================================================================*/
18 /*
19  * See :
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,
23  * sequence...
24  */
25  
26  // Well ... ReWrite.cxx does the same thing
27  
28 #include "gdcmFile.h"
29 #include "gdcmFileHelper.h"
30 #include "gdcmDocument.h"
31
32 int main(int argc, char *argv[])
33 {
34   if (argc < 3) 
35     {
36     std::cerr << "Usage :" << std::endl << argv[0] << 
37       " InputHeader OutputDicom" << std::endl;
38     return 0;
39     }
40
41   const char *inputfilename = argv[1];
42   const char *outputfilename = argv[2];
43
44   GDCM_NAME_SPACE::File *input = new GDCM_NAME_SPACE::File( );
45   input->SetFileName( inputfilename );
46 //  input->SetLoadMode(loadMode);
47   input->Load();
48   if ( input->IsReadable() )
49     {
50     GDCM_NAME_SPACE::FileHelper *output = new GDCM_NAME_SPACE::FileHelper( input );
51
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();
56
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 );
62
63     delete output;
64     }
65   delete input;
66
67   return 0;
68 }
69