in src/dcmtkUtils.cpp [154:213]
OFCondition insertPixelMetadata(DcmDataset* dataset,
const DcmtkImgDataInfo& imgInfo, uint32_t numberOfFrames) {
OFCondition cond =
dataset->putAndInsertUint16(DCM_SamplesPerPixel, imgInfo.samplesPerPixel);
if (cond.bad()) return cond;
cond = dataset->putAndInsertOFStringArray(DCM_PhotometricInterpretation,
imgInfo.photoMetrInt);
if (cond.bad()) return cond;
cond = dataset->putAndInsertUint16(DCM_PlanarConfiguration, imgInfo.planConf);
if (cond.bad()) return cond;
cond = dataset->putAndInsertUint16(DCM_Rows, imgInfo.rows);
if (cond.bad()) return cond;
cond = dataset->putAndInsertUint16(DCM_Columns, imgInfo.cols);
if (cond.bad()) return cond;
cond = dataset->putAndInsertUint16(DCM_BitsAllocated, imgInfo.bitsAlloc);
if (cond.bad()) return cond;
cond = dataset->putAndInsertUint16(DCM_BitsStored, imgInfo.bitsStored);
if (cond.bad()) return cond;
cond = dataset->putAndInsertUint16(DCM_HighBit, imgInfo.highBit);
if (cond.bad()) return cond;
if (numberOfFrames >= 1) {
char buf[10];
int err = snprintf(buf, sizeof(buf), "%u", numberOfFrames);
if (err == -1) return EC_IllegalCall;
cond = dataset->putAndInsertOFStringArray(DCM_NumberOfFrames, buf);
if (cond.bad()) return cond;
std::string lossy = "00";
if (imgInfo.transSyn == EXS_JPEGProcess1) {
lossy = "01";
cond = dataset->putAndInsertOFStringArray(DCM_LossyImageCompressionMethod,
"ISO_10918_1", true);
if (cond.bad()) return cond;
cond = dataset->putAndInsertOFStringArray(DCM_LossyImageCompressionRatio,
imgInfo.compressionRatio.c_str());
if (cond.bad()) return cond;
}
cond = dataset->putAndInsertOFStringArray(DCM_LossyImageCompression,
lossy.c_str(), true);
// DerivationDescription is text constructed from image source
// and frame generation text. See dcmFileDraft.cpp for
// construction of image source and frame representation components.
if (cond.bad()) return cond;
cond = dataset->putAndInsertOFStringArray(DCM_DerivationDescription,
imgInfo.derivationDescription.c_str(),
true);
if (cond.bad()) return cond;
}
return dataset->putAndInsertUint16(DCM_PixelRepresentation,
imgInfo.pixelRepr);
}