# HG changeset patch # User Sebastien Jodogne # Date 1783081820 -7200 # Node ID f70c531812443c628ee653034af62df3ba5d2aec # Parent e716a4dd547c60d2df5fb415fec7eb959799758b support older versions of dcmtk diff -r e716a4dd547c -r f70c53181244 OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp --- a/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp Fri Jul 03 14:16:44 2026 +0200 +++ b/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp Fri Jul 03 14:30:20 2026 +0200 @@ -1117,28 +1117,38 @@ // Support for multiple values was added in Orthanc 1.12.12 DcmAttributeTag& content = dynamic_cast(element); - ChunkedBuffer buffer; - for (unsigned long i = 0; i < content.getNumberOfValues(); i++) + Uint16* uint16Array = NULL; + if (content.getUint16Array(uint16Array).good() && uint16Array != NULL) { - if (i > 0) + if (element.getLength() % sizeof(Uint16) != 0) { - buffer.AddChunk("\\", 1); + throw OrthancException(ErrorCode_BadFileFormat); } - DcmTagKey tag; - if (content.getTagVal(tag, i).good()) + const uint64_t numValues = static_cast(element.getLength()) / sizeof(Uint16); + if (numValues % 2 != 0) { - buffer.AddChunk(DicomTag(tag.getGroup(), tag.getElement()).Format()); - } - else - { - return new DicomValue; + throw OrthancException(ErrorCode_BadFileFormat); } + + ChunkedBuffer buffer; + for (uint64_t i = 0; i < numValues; i += 2) + { + if (i > 0) + { + buffer.AddChunk("\\", 1); + } + + const DicomTag tag(uint16Array[i], uint16Array[i + 1]); + buffer.AddChunk(tag.Format()); + } + + std::string s; + buffer.Flatten(s); + return DicomValue::CreateFromSwap(s, false); } - std::string s; - buffer.Flatten(s); - return DicomValue::CreateFromSwap(s, false); + return new DicomValue; }