3 int main(int argc, char* argv[])
8 std::cerr << "Usage :" << std::endl << argv[0] <<
9 " InputHeader OutputDicom" << std::endl;
13 std::string header = argv[1];
14 const char *output = argv[2];
16 gdcm::Header *f1 = new gdcm::Header( header );
17 gdcm::File *f2 = new gdcm::File( f1 );
19 // If the following call is important, then the API sucks. Why is it
20 // required to allocate PixelData when we are not using it !?
21 void* PixelData = f2->GetImageData(); //EXTREMELY IMPORTANT
22 //Otherwise ReadPixel == -1 -> the dicom writing fails completely
24 int dataSize = f2->GetImageDataSize();
25 // unsigned char cast is necessary to be able to delete the buffer
26 // since deleting a void* is not allowed in c++
27 uint8_t* imageData = (uint8_t*)f2->GetImageData();
29 f2->SetImageData( imageData, dataSize);
31 f2->WriteDcmExplVR( output );
36 //delete PixelData; //Does GetImageData return the same pointer ?