1 #include "gdcmHeader.h"
5 // Writting of a DICOM file, using a correct gdcmHeader.
6 // and pixels of an other image
9 int TestChangeHeader(int argc, char* argv[])
13 std::cerr << "usage :" << std::endl <<
14 argv[0] << " FileForHeader FileForPixels" << std::endl;
18 std::string premier = argv[1];
19 gdcmFile *f1 = new gdcmFile(premier);
21 std::string deuxieme = argv[2];
22 gdcmFile *f2 = new gdcmFile(deuxieme);
24 //f1->PrintPubElVal();
26 // We suppose the DICOM Entries of the second file *do* exist !
28 std::string nbFrames = f2->GetHeader()->GetEntryByNumber(0x0028, 0x0008);
29 if(nbFrames != "gdcm::Unfound")
31 f1->GetHeader()->ReplaceOrCreateByNumber( nbFrames, 0x0028, 0x0008);
34 f1->GetHeader()->ReplaceOrCreateByNumber(
35 f2->GetHeader()->GetEntryByNumber(0x0028, 0x0010), 0x0028, 0x0010);// nbLig
36 f1->GetHeader()->ReplaceOrCreateByNumber(
37 f2->GetHeader()->GetEntryByNumber(0x0028, 0x0011), 0x0028, 0x0011);// nbCol
39 // Probabely some more to update (?)
41 // TODO : add a default value
42 // TODO : add a method that receives a list of pairs (gr,el),
43 // and that does the work.
45 int dataSize = f2->GetImageDataSize();
46 printf ("dataSize %d\n",dataSize);
47 void* imageData= f2->GetImageData();
49 // TODO : Why don't we merge theese 2 functions ?
51 f1->SetImageData(imageData,dataSize);
52 f1->GetHeader()->SetImageDataSize(dataSize);
54 f1->GetHeader()->Print();
56 std::string s0 =f2->GetHeader()->GetEntryByNumber(0x7fe0, 0x0000);
57 std::string s10=f2->GetHeader()->GetEntryByNumber(0x7fe0, 0x0010);
58 printf("lgr 7fe0, 0000 %s\n",s0.c_str());
59 printf("lgr 7fe0, 0010 %s\n",s10.c_str());
63 sprintf(resultat, "%s.vol", deuxieme.c_str());
64 printf ("WriteDCM\n");
65 //f1->WriteDcmExplVR("itk-gdcm-ex.dcm");
66 //f1->WriteDcmImplVR(resultat);
67 f1->WriteAcr(resultat);