1 /*=========================================================================
4 Module: $RCSfile: TestWriteSimple.cxx,v $
6 Date: $Date: 2005/07/08 12:02:02 $
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 =========================================================================*/
19 #include "gdcmFileHelper.h"
21 int main(int argc, char *argv[])
25 std::cerr << "Usage :" << std::endl << argv[0]
26 << " InputFile OutputDicom" << std::endl;
30 std::string header = argv[1];
31 const char *output = argv[2];
33 gdcm::File *f1 = new gdcm::File( );
34 f1->SetFileName ( header );
37 gdcm::FileHelper *f2 = new gdcm::FileHelper( f1 );
39 // If the following call is important, then the API sucks. Why is it
40 // required to allocate PixelData when we are not using it !?
41 uint8_t* PixelData = f2->GetImageData(); //EXTREMELY IMPORTANT
42 //Otherwise ReadPixel == -1 -> the dicom writing fails completely
44 int dataSize = f2->GetImageDataSize();
45 // unsigned char cast is necessary to be able to delete the buffer
46 // since deleting a void* is not allowed in c++
47 uint8_t *imageData = (uint8_t *)f2->GetImageData();
49 f2->SetImageData( imageData, dataSize );
51 f2->WriteDcmExplVR( output );
55 //delete PixelData; //Does GetImageData return the same pointer ?