changeset 4957:94edc2c89768 more-tags

integration mainline->more-tags
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 23 Mar 2022 11:49:08 +0100
parents e1495a34cd39 (current diff) 964bbf5cb365 (diff)
children 501411a67f10
files
diffstat 2 files changed, 19 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Sources/DicomParsing/ParsedDicomFile.cpp	Tue Mar 22 19:11:56 2022 +0100
+++ b/OrthancFramework/Sources/DicomParsing/ParsedDicomFile.cpp	Wed Mar 23 11:49:08 2022 +0100
@@ -1962,8 +1962,8 @@
     Uint16 rows, columns, bitsAllocated, bitPosition;
     const Sint16* origin = NULL;
     unsigned long originSize = 0;
-    const Uint8* overlayData = NULL;
-    unsigned long overlaySize = 0;
+    DcmElement* overlayElement = NULL;
+    Uint8* overlayData = NULL;
     
     if (dataset.findAndGetUint16(DcmTagKey(group, 0x0010), rows).good() &&
         dataset.findAndGetUint16(DcmTagKey(group, 0x0011), columns).good() &&
@@ -1974,11 +1974,25 @@
         bitsAllocated == 1 &&
         dataset.findAndGetUint16(DcmTagKey(group, 0x0102), bitPosition).good() &&
         bitPosition == 0 &&
-        dataset.findAndGetUint8Array(DcmTagKey(group, 0x3000), overlayData, &overlaySize).good() &&
+        dataset.findAndGetElement(DcmTagKey(group, 0x3000), overlayElement).good() &&
+        overlayElement != NULL &&
+        overlayElement->getUint8Array(overlayData).good() &&
         overlayData != NULL)
     {
+      /**
+       * WARNING - It might seem easier to use
+       * "dataset.findAndGetUint8Array()" that directly gives the size
+       * of the overlay data (using the "count" parameter), instead of
+       * "dataset.findAndGetElement()". Unfortunately, this does *not*
+       * work with Emscripten/WebAssembly, that reports a "count" that
+       * is half the number of bytes, presumably because of
+       * discrepancies in the way sizeof are computed inside DCMTK.
+       * The method "getLengthField()" reports the correct number of
+       * bytes, even if targeting WebAssembly.
+       **/
+
       unsigned int expectedSize = Ceiling(rows * columns, 8);
-      if (overlaySize < expectedSize)
+      if (overlayElement->getLengthField() < expectedSize)
       {
         throw OrthancException(ErrorCode_CorruptedFile, "Overlay doesn't have a valid number of bits");
       }
--- a/OrthancServer/Plugins/Engine/OrthancPlugins.cpp	Tue Mar 22 19:11:56 2022 +0100
+++ b/OrthancServer/Plugins/Engine/OrthancPlugins.cpp	Wed Mar 23 11:49:08 2022 +0100
@@ -95,7 +95,7 @@
       std::vector<const char*>  items_;
 
     public:
-      PathHelper(const std::vector<std::string>& path)
+      explicit PathHelper(const std::vector<std::string>& path)
       {
         items_.resize(path.size());
         for (size_t i = 0; i < path.size(); i++)