diff OrthancServer/FromDcmtkBridge.cpp @ 369:4632a044746e

simplification of the code
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 19 Feb 2013 12:09:03 +0100
parents 80011cd589e6
children 4d5f0857ec9c
line wrap: on
line diff
--- a/OrthancServer/FromDcmtkBridge.cpp	Mon Feb 18 16:07:28 2013 +0100
+++ b/OrthancServer/FromDcmtkBridge.cpp	Tue Feb 19 12:09:03 2013 +0100
@@ -1242,43 +1242,51 @@
     }
 
     PixelFormat format;
+    bool supported = false;
 
-    if (accessor->GetChannelCount() != 1 &&
-        (mode == ImageExtractionMode_UInt8 ||
-         mode == ImageExtractionMode_UInt16))
+    if (accessor->GetChannelCount() == 1)
+    {
+      switch (mode)
+      {
+        case ImageExtractionMode_Preview:
+          supported = true;
+          format = PixelFormat_Grayscale8;
+          break;
+
+        case ImageExtractionMode_UInt8:
+          supported = true;
+          format = PixelFormat_Grayscale8;
+          break;
+
+        case ImageExtractionMode_UInt16:
+          supported = true;
+          format = PixelFormat_Grayscale16;
+          break;
+
+        default:
+          supported = false;
+          break;
+      }
+    }
+    else if (accessor->GetChannelCount() == 3)
+    {
+      switch (mode)
+      {
+        case ImageExtractionMode_Preview:
+          supported = true;
+          format = PixelFormat_RGB24;
+          break;
+
+        default:
+          supported = false;
+          break;
+      }
+    }
+
+    if (!supported)
     {
       throw OrthancException(ErrorCode_NotImplemented);
-    }
-    
-    switch (mode)
-    {
-      case ImageExtractionMode_Preview:
-        switch (accessor->GetChannelCount())
-        {
-          case 1:
-            format = PixelFormat_Grayscale8;
-            break;
-
-          case 3:
-            format = PixelFormat_RGB24;
-            break;
-
-          default:
-            throw OrthancException(ErrorCode_NotImplemented);
-        }
-        break;
-
-      case ImageExtractionMode_UInt8:
-        format = PixelFormat_Grayscale8;
-        break;
-
-      case ImageExtractionMode_UInt16:
-        format = PixelFormat_Grayscale16;
-        break;
-
-      default:
-        throw OrthancException(ErrorCode_NotImplemented);
-    }
+    }   
 
     if (accessor.get() == NULL ||
         accessor->GetWidth() == 0 ||