From a dump i saw the following: (0018,1164) DS [0.086196\0.086215] # 18, 2 ImagerPixelSpacing
My first thought was to use "findAndGetOFString" which gave 0.086196 as result. okay i thought the \0 is the end of a string - so you have to use
an array as follow
Code: Select all
OFString *pixelSpacingStringArray = (OFString*) malloc(2 * sizeof(OFString));
if (!pixelSpacingStringArray){
qDebug() << "malloc error!";
pixelSpacingHorizontal = 0.0;
pixelSpacingVertikal = 0.0;
}
else{
qDebug() << "malloc okay";
if((dataset->findAndGetOFStringArray(DCM_ImagerPixelSpacing, *pixelSpacingStringArray,false).good())
||
(dataset->findAndGetOFStringArray(DCM_PixelSpacing, *pixelSpacingStringArray,false).good()) )
{
qDebug() << "spacing string: " << pixelSpacingStringArray[0].c_str();
qDebug() << "spacing string: " << pixelSpacingStringArray[1].c_str();
free(pixelSpacingStringArray); // free malloced memory
}
else{
pixelSpacingHorizontal = 0.0;
pixelSpacingVertikal = 0.0;
}
01:18:05 Debug: spacing string: 0.086196\0.086215
01:18:05 Debug: spacing string:
So my feeling is GetArrayOfOFstring doesn't look for the \0 and copies the whole string while GetOFString
doesn't copy the whole string because of the \0. :>
I'm using the dcmtk-3.6.1_20120222 (VC++ 2010 release build)
Btw for a hint to make it better would be nice.
Frank