changeset 328:c80b5bddf86b am-2

support of monochrome1
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 17 Oct 2018 10:26:33 +0200
parents 8716176ff7f0
children b10dfdb96866
files Framework/Layers/GrayscaleFrameRenderer.cpp Framework/Layers/GrayscaleFrameRenderer.h Framework/Toolbox/DicomFrameConverter.cpp Framework/Toolbox/DicomFrameConverter.h
diffstat 4 files changed, 14 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Layers/GrayscaleFrameRenderer.cpp	Tue Oct 16 15:25:21 2018 +0200
+++ b/Framework/Layers/GrayscaleFrameRenderer.cpp	Wed Oct 17 10:26:33 2018 +0200
@@ -81,7 +81,7 @@
             v = static_cast<uint8_t>(255.0f * (*p - x0) / (x1 - x0));
           }
 
-          if (style.reverse_)
+          if (style.reverse_ ^ (photometric_ == Orthanc::PhotometricInterpretation_Monochrome1))
           {
             v = 255 - v;
           }
@@ -118,7 +118,8 @@
     FrameRenderer(frameSlice, pixelSpacingX, pixelSpacingY, isFullQuality),
     frame_(frame),
     defaultWindowCenter_(converter.GetDefaultWindowCenter()),
-    defaultWindowWidth_(converter.GetDefaultWindowWidth())
+    defaultWindowWidth_(converter.GetDefaultWindowWidth()),
+    photometric_(converter.GetPhotometricInterpretation())
   {
     if (frame == NULL)
     {
--- a/Framework/Layers/GrayscaleFrameRenderer.h	Tue Oct 16 15:25:21 2018 +0200
+++ b/Framework/Layers/GrayscaleFrameRenderer.h	Wed Oct 17 10:26:33 2018 +0200
@@ -32,6 +32,7 @@
     std::auto_ptr<Orthanc::ImageAccessor>   frame_;  // In Float32
     float                                   defaultWindowCenter_;
     float                                   defaultWindowWidth_;
+    Orthanc::PhotometricInterpretation      photometric_;
 
   protected:
     virtual CairoSurface* GenerateDisplay(const RenderStyle& style);
--- a/Framework/Toolbox/DicomFrameConverter.cpp	Tue Oct 16 15:25:21 2018 +0200
+++ b/Framework/Toolbox/DicomFrameConverter.cpp	Wed Oct 17 10:26:33 2018 +0200
@@ -113,6 +113,8 @@
       // Type 1 tag, must be present
       throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
     }
+
+    photometric_ = Orthanc::StringToPhotometricInterpretation(photometric.c_str());
     
     isColor_ = (photometric != "MONOCHROME1" &&
                 photometric != "MONOCHROME2");
--- a/Framework/Toolbox/DicomFrameConverter.h	Tue Oct 16 15:25:21 2018 +0200
+++ b/Framework/Toolbox/DicomFrameConverter.h	Wed Oct 17 10:26:33 2018 +0200
@@ -45,8 +45,9 @@
     double  rescaleSlope_;
     double  defaultWindowCenter_;
     double  defaultWindowWidth_;
-
-    Orthanc::PixelFormat  expectedPixelFormat_;
+    
+    Orthanc::PhotometricInterpretation  photometric_;
+    Orthanc::PixelFormat                expectedPixelFormat_;
 
     void SetDefaultParameters();
 
@@ -61,6 +62,11 @@
       return expectedPixelFormat_;
     }
 
+    Orthanc::PhotometricInterpretation GetPhotometricInterpretation() const
+    {
+      return photometric_;
+    }
+
     void ReadParameters(const Orthanc::DicomMap& dicom);
 
     double GetDefaultWindowCenter() const