diff Core/DicomFormat/DicomIntegerPixelAccessor.cpp @ 857:f53358c70c05 jpeg

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 06 Jun 2014 15:01:19 +0200
parents ff530685e46a
children 80c7e53a69b5
line wrap: on
line diff
--- a/Core/DicomFormat/DicomIntegerPixelAccessor.cpp	Fri Jun 06 13:15:47 2014 +0200
+++ b/Core/DicomFormat/DicomIntegerPixelAccessor.cpp	Fri Jun 06 15:01:19 2014 +0200
@@ -78,6 +78,15 @@
     if (information_.IsPlanar())
     {
       /**
+       * Each color plane shall be sent contiguously. For RGB images,
+       * this means the order of the pixel values sent is R1, R2, R3,
+       * ..., G1, G2, G3, ..., B1, B2, B3, etc.
+       **/
+      rowOffset_ = information_.GetWidth() * information_.GetBytesPerPixel();
+    }
+    else
+    {
+      /**
        * The sample values for the first pixel are followed by the
        * sample values for the second pixel, etc. For RGB images, this
        * means the order of the pixel values sent shall be R1, G1, B1,
@@ -85,15 +94,6 @@
        **/
       rowOffset_ = information_.GetWidth() * information_.GetBytesPerPixel() * information_.GetChannelCount();
     }
-    else
-    {
-      /**
-       * Each color plane shall be sent contiguously. For RGB images,
-       * this means the order of the pixel values sent is R1, R2, R3,
-       * ..., G1, G2, G3, ..., B1, B2, B3, etc.
-       **/
-      rowOffset_ = information_.GetWidth() * information_.GetBytesPerPixel();
-    }
   }
 
 
@@ -130,13 +130,25 @@
                                               unsigned int y,
                                               unsigned int channel) const
   {
-    assert(x < information_.GetWidth() && y < information_.GetHeight() && channel < information_.GetChannelCount());
+    assert(x < information_.GetWidth() && 
+           y < information_.GetHeight() && 
+           channel < information_.GetChannelCount());
     
     const uint8_t* pixel = reinterpret_cast<const uint8_t*>(pixelData_) + 
       y * rowOffset_ + frame_ * frameOffset_;
 
     // https://www.dabsoft.ch/dicom/3/C.7.6.3.1.3/
-    if (information_.IsPlanar() == 0)
+    if (information_.IsPlanar())
+    {
+      /**
+       * Each color plane shall be sent contiguously. For RGB images,
+       * this means the order of the pixel values sent is R1, R2, R3,
+       * ..., G1, G2, G3, ..., B1, B2, B3, etc.
+       **/
+      assert(frameOffset_ % information_.GetChannelCount() == 0);
+      pixel += channel * frameOffset_ / information_.GetChannelCount() + x * information_.GetBytesPerPixel();
+    }
+    else
     {
       /**
        * The sample values for the first pixel are followed by the
@@ -146,16 +158,6 @@
        **/
       pixel += channel * information_.GetBytesPerPixel() + x * information_.GetChannelCount() * information_.GetBytesPerPixel();
     }
-    else
-    {
-      /**
-       * Each color plane shall be sent contiguously. For RGB images,
-       * this means the order of the pixel values sent is R1, R2, R3,
-       * ..., G1, G2, G3, ..., B1, B2, B3, etc.
-       **/
-      assert(frameOffset_ % information_.GetChannelCount() == 0);
-      pixel += channel * frameOffset_ / information_.GetChannelCount() + x * information_.GetBytesPerPixel();
-    }
 
     uint32_t v;
     v = pixel[0];