1 #include "gdcmHeader.h"
6 int TestWriteSimple(int argc, char* argv[])
11 std::cerr << "Usage :" << std::endl << argv[0] <<
12 " InputHeader OutputDicom" << std::endl;
16 const char *header = argv[1];
17 const char *output = argv[2];
20 gdcmHeader *f1 = new gdcmHeader( header );
21 gdcmFile *f2 = new gdcmFile( f1 );
23 f2->GetImageData(); //EXTREMELY IMPORTANT
24 //Otherwise ReadPixel == -1 -> the dicom writing fails completely
26 int dataSize = f2->GetImageDataSize();
27 // unsigned char cast is necessary to be able to delete the buffer
28 // since deleting a void* is not allowed in c++
29 char *imageData = (char*)f2->GetImageData();
31 f2->SetImageData( imageData, dataSize);
33 f2->WriteDcmExplVR( output );