Mercurial > hg > orthanc
changeset 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 | 22bb88181e06 0ef82ea18da0 |
files | Core/DicomFormat/DicomIntegerPixelAccessor.cpp NEWS OrthancServer/FromDcmtkBridge.cpp UnitTests/PngWriter.cpp |
diffstat | 4 files changed, 46 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/Core/DicomFormat/DicomIntegerPixelAccessor.cpp Mon Feb 18 16:07:28 2013 +0100 +++ b/Core/DicomFormat/DicomIntegerPixelAccessor.cpp Tue Feb 19 12:09:03 2013 +0100 @@ -121,8 +121,7 @@ throw OrthancException(ErrorCode_NotImplemented); } - if (samplesPerPixel_ != 1 && - samplesPerPixel_ != 3) + if (samplesPerPixel_ == 0) { throw OrthancException(ErrorCode_NotImplemented); }
--- a/NEWS Mon Feb 18 16:07:28 2013 +0100 +++ b/NEWS Tue Feb 19 12:09:03 2013 +0100 @@ -1,6 +1,7 @@ Pending changes in the mainline =============================== +* Support of RGB images Version 0.5.0 (2013/01/31)
--- 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 ||
--- a/UnitTests/PngWriter.cpp Mon Feb 18 16:07:28 2013 +0100 +++ b/UnitTests/PngWriter.cpp Tue Feb 19 12:09:03 2013 +0100 @@ -50,9 +50,10 @@ Orthanc::PngWriter w; int width = 256; int height = 256; - int pitch = width * 2 + 17; + int pitch = width * 2 + 16; std::vector<uint8_t> image(height * pitch); + int v = 0; for (int y = 0; y < height; y++) {