Mercurial > hg > orthanc
comparison 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 |
comparison
equal
deleted
inserted
replaced
856:6944fc00962e | 857:f53358c70c05 |
---|---|
76 } | 76 } |
77 | 77 |
78 if (information_.IsPlanar()) | 78 if (information_.IsPlanar()) |
79 { | 79 { |
80 /** | 80 /** |
81 * Each color plane shall be sent contiguously. For RGB images, | |
82 * this means the order of the pixel values sent is R1, R2, R3, | |
83 * ..., G1, G2, G3, ..., B1, B2, B3, etc. | |
84 **/ | |
85 rowOffset_ = information_.GetWidth() * information_.GetBytesPerPixel(); | |
86 } | |
87 else | |
88 { | |
89 /** | |
81 * The sample values for the first pixel are followed by the | 90 * The sample values for the first pixel are followed by the |
82 * sample values for the second pixel, etc. For RGB images, this | 91 * sample values for the second pixel, etc. For RGB images, this |
83 * means the order of the pixel values sent shall be R1, G1, B1, | 92 * means the order of the pixel values sent shall be R1, G1, B1, |
84 * R2, G2, B2, ..., etc. | 93 * R2, G2, B2, ..., etc. |
85 **/ | 94 **/ |
86 rowOffset_ = information_.GetWidth() * information_.GetBytesPerPixel() * information_.GetChannelCount(); | 95 rowOffset_ = information_.GetWidth() * information_.GetBytesPerPixel() * information_.GetChannelCount(); |
87 } | |
88 else | |
89 { | |
90 /** | |
91 * Each color plane shall be sent contiguously. For RGB images, | |
92 * this means the order of the pixel values sent is R1, R2, R3, | |
93 * ..., G1, G2, G3, ..., B1, B2, B3, etc. | |
94 **/ | |
95 rowOffset_ = information_.GetWidth() * information_.GetBytesPerPixel(); | |
96 } | 96 } |
97 } | 97 } |
98 | 98 |
99 | 99 |
100 void DicomIntegerPixelAccessor::GetExtremeValues(int32_t& min, | 100 void DicomIntegerPixelAccessor::GetExtremeValues(int32_t& min, |
128 | 128 |
129 int32_t DicomIntegerPixelAccessor::GetValue(unsigned int x, | 129 int32_t DicomIntegerPixelAccessor::GetValue(unsigned int x, |
130 unsigned int y, | 130 unsigned int y, |
131 unsigned int channel) const | 131 unsigned int channel) const |
132 { | 132 { |
133 assert(x < information_.GetWidth() && y < information_.GetHeight() && channel < information_.GetChannelCount()); | 133 assert(x < information_.GetWidth() && |
134 y < information_.GetHeight() && | |
135 channel < information_.GetChannelCount()); | |
134 | 136 |
135 const uint8_t* pixel = reinterpret_cast<const uint8_t*>(pixelData_) + | 137 const uint8_t* pixel = reinterpret_cast<const uint8_t*>(pixelData_) + |
136 y * rowOffset_ + frame_ * frameOffset_; | 138 y * rowOffset_ + frame_ * frameOffset_; |
137 | 139 |
138 // https://www.dabsoft.ch/dicom/3/C.7.6.3.1.3/ | 140 // https://www.dabsoft.ch/dicom/3/C.7.6.3.1.3/ |
139 if (information_.IsPlanar() == 0) | 141 if (information_.IsPlanar()) |
142 { | |
143 /** | |
144 * Each color plane shall be sent contiguously. For RGB images, | |
145 * this means the order of the pixel values sent is R1, R2, R3, | |
146 * ..., G1, G2, G3, ..., B1, B2, B3, etc. | |
147 **/ | |
148 assert(frameOffset_ % information_.GetChannelCount() == 0); | |
149 pixel += channel * frameOffset_ / information_.GetChannelCount() + x * information_.GetBytesPerPixel(); | |
150 } | |
151 else | |
140 { | 152 { |
141 /** | 153 /** |
142 * The sample values for the first pixel are followed by the | 154 * The sample values for the first pixel are followed by the |
143 * sample values for the second pixel, etc. For RGB images, this | 155 * sample values for the second pixel, etc. For RGB images, this |
144 * means the order of the pixel values sent shall be R1, G1, B1, | 156 * means the order of the pixel values sent shall be R1, G1, B1, |
145 * R2, G2, B2, ..., etc. | 157 * R2, G2, B2, ..., etc. |
146 **/ | 158 **/ |
147 pixel += channel * information_.GetBytesPerPixel() + x * information_.GetChannelCount() * information_.GetBytesPerPixel(); | 159 pixel += channel * information_.GetBytesPerPixel() + x * information_.GetChannelCount() * information_.GetBytesPerPixel(); |
148 } | |
149 else | |
150 { | |
151 /** | |
152 * Each color plane shall be sent contiguously. For RGB images, | |
153 * this means the order of the pixel values sent is R1, R2, R3, | |
154 * ..., G1, G2, G3, ..., B1, B2, B3, etc. | |
155 **/ | |
156 assert(frameOffset_ % information_.GetChannelCount() == 0); | |
157 pixel += channel * frameOffset_ / information_.GetChannelCount() + x * information_.GetBytesPerPixel(); | |
158 } | 160 } |
159 | 161 |
160 uint32_t v; | 162 uint32_t v; |
161 v = pixel[0]; | 163 v = pixel[0]; |
162 if (information_.GetBytesPerPixel() >= 2) | 164 if (information_.GetBytesPerPixel() >= 2) |