comparison Core/DicomFormat/DicomImageInformation.cpp @ 3007:c9f93628215a

more error details
author am@osimis.io
date Thu, 13 Dec 2018 14:48:23 +0100
parents 716dd24974ef
children 4e43e67f8ecf
comparison
equal deleted inserted replaced
3000:3ca27070df78 3007:c9f93628215a
18 * modify file(s) with this exception, you may extend this exception to 18 * modify file(s) with this exception, you may extend this exception to
19 * your version of the file(s), but you are not obligated to do so. If 19 * your version of the file(s), but you are not obligated to do so. If
20 * you do not wish to do so, delete this exception statement from your 20 * you do not wish to do so, delete this exception statement from your
21 * version. If you delete this exception statement from all source files 21 * version. If you delete this exception statement from all source files
22 * in the program, then also delete it here. 22 * in the program, then also delete it here.
23 * 23 *
24 * This program is distributed in the hope that it will be useful, but 24 * This program is distributed in the hope that it will be useful, but
25 * WITHOUT ANY WARRANTY; without even the implied warranty of 25 * WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * General Public License for more details. 27 * General Public License for more details.
28 * 28 *
193 else 193 else
194 { 194 {
195 numberOfFrames_ = 1; 195 numberOfFrames_ = 1;
196 } 196 }
197 197
198 if ((bitsAllocated_ != 8 && bitsAllocated_ != 16 && 198 if (bitsAllocated_ != 8 && bitsAllocated_ != 16 &&
199 bitsAllocated_ != 24 && bitsAllocated_ != 32) || 199 bitsAllocated_ != 24 && bitsAllocated_ != 32)
200 numberOfFrames_ == 0 || 200 {
201 (planarConfiguration != 0 && planarConfiguration != 1)) 201 throw OrthancException(ErrorCode_IncompatibleImageFormat, "Image not supported: " + boost::lexical_cast<std::string>(bitsAllocated_) + " bits allocated");
202 { 202 }
203 throw OrthancException(ErrorCode_NotImplemented); 203 else if (numberOfFrames_ == 0)
204 {
205 throw OrthancException(ErrorCode_IncompatibleImageFormat, "Image not supported (no frames)");
206 }
207 else if (planarConfiguration != 0 && planarConfiguration != 1)
208 {
209 throw OrthancException(ErrorCode_IncompatibleImageFormat, "Image not supported: planar configuration is " + boost::lexical_cast<std::string>(planarConfiguration));
204 } 210 }
205 211
206 if (samplesPerPixel_ == 0) 212 if (samplesPerPixel_ == 0)
207 { 213 {
208 throw OrthancException(ErrorCode_NotImplemented); 214 throw OrthancException(ErrorCode_IncompatibleImageFormat, "Image not supported: samples per pixel is 0");
209 } 215 }
210 216
211 bytesPerValue_ = bitsAllocated_ / 8; 217 bytesPerValue_ = bitsAllocated_ / 8;
212 218
213 isPlanar_ = (planarConfiguration != 0 ? true : false); 219 isPlanar_ = (planarConfiguration != 0 ? true : false);
277 format = PixelFormat_Grayscale32; 283 format = PixelFormat_Grayscale32;
278 return true; 284 return true;
279 } 285 }
280 } 286 }
281 287
282 if (GetBitsStored() == 8 && 288 if (GetBitsStored() == 8 &&
283 GetChannelCount() == 3 && 289 GetChannelCount() == 3 &&
284 !IsSigned() && 290 !IsSigned() &&
285 (ignorePhotometricInterpretation || photometric_ == PhotometricInterpretation_RGB)) 291 (ignorePhotometricInterpretation || photometric_ == PhotometricInterpretation_RGB))
286 { 292 {
287 format = PixelFormat_RGB24; 293 format = PixelFormat_RGB24;
288 return true; 294 return true;
292 } 298 }
293 299
294 300
295 size_t DicomImageInformation::GetFrameSize() const 301 size_t DicomImageInformation::GetFrameSize() const
296 { 302 {
297 return (GetHeight() * 303 return (GetHeight() *
298 GetWidth() * 304 GetWidth() *
299 GetBytesPerValue() * 305 GetBytesPerValue() *
300 GetChannelCount()); 306 GetChannelCount());
301 } 307 }
302 } 308 }