Thanks for the answer.
Yes, I need something along the lines of the example from that HOWTO. But the example doesn't show how the private tags are read from the file and that's the part that doesn't work for me.
My understanding is that following code should print out "123", but it prints "31" i.e. it doesn't read the string value correctly. Can you please point me to what I am doing wrong? I tried to make the code as shorter as possible but still complete:
Code: Select all
#include "dcmtk/config/osconfig.h"
#include "dcmtk/dcmdata/dctk.h"
#define PRIVATE_CREATOR_NAME "MY PRIVATE CREATOR NAME"
#define TEST_ELEMENT_TAG 0x2929, 0x3709
#define TEST_ELEMENT_NAME "Test Element Name"
#define TEST_ELEMENT DcmTag(TEST_ELEMENT_TAG, "IS")
int main()
{
DcmDataDictionary &dict = dcmDataDict.wrlock();
dict.addEntry(new DcmDictEntry(TEST_ELEMENT_TAG, EVR_IS, TEST_ELEMENT_NAME, 1, 1, "private", OFTrue, PRIVATE_CREATOR_NAME));
dcmDataDict.unlock();
DcmFileFormat inFile;
nFile.loadFile("c:\\2.dcm");
DcmDataset *dataset = inFile.getDataset();
dataset->putAndInsertString(TEST_ELEMENT, "123");
inFile.saveFile("c:\\2_edit.dcm");
inFile.loadFile("c:\\2_edit.dcm");
dataset = inFile.getDataset();
OFString tempString;
dataset->findAndGetOFString(TEST_ELEMENT, tempString);
std::cout << tempString.c_str() << std::endl;
return 0;
}
None of the functions return error. I removed the checks here to make the code short.
Also, I think there's an error in the HOWTO example:
Code: Select all
#define PRV_PrivateElement1 DcmTag(PRIVATE_ELEMENT1_TAG, PRIVATE_CREATOR_NAME)
Should be:
Code: Select all
#define PRV_PrivateElement1 DcmTag(PRIVATE_ELEMENT1_TAG, "LO")