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 std::string header = argv[1];
17 const char *output = argv[2];
19 gdcmHeader *f1 = new gdcmHeader( header );
20 gdcmFile *f2 = new gdcmFile( f1 );
22 // If the following call is important, then the API sucks. Why is it
23 // required to allocate PixelData when we are not using it !?
24 void* PixelData = f2->GetImageData(); //EXTREMELY IMPORTANT
25 //Otherwise ReadPixel == -1 -> the dicom writing fails completely
27 int dataSize = f2->GetImageDataSize();
28 // unsigned char cast is necessary to be able to delete the buffer
29 // since deleting a void* is not allowed in c++
30 char *imageData = (char*)f2->GetImageData();
32 f2->SetImageData( imageData, dataSize);
34 f2->WriteDcmExplVR( output );
39 //delete PixelData; //Does GetImageData return the same pointer ?