# HG changeset patch # User Sebastien Jodogne # Date 1361272143 -3600 # Node ID 4632a044746ebabb04a572d3bd2046384591683a # Parent 80011cd589e641fee934de0ded8c7c51047a131e simplification of the code diff -r 80011cd589e6 -r 4632a044746e Core/DicomFormat/DicomIntegerPixelAccessor.cpp --- 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); } diff -r 80011cd589e6 -r 4632a044746e NEWS --- 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) diff -r 80011cd589e6 -r 4632a044746e OrthancServer/FromDcmtkBridge.cpp --- 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 || diff -r 80011cd589e6 -r 4632a044746e UnitTests/PngWriter.cpp --- 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 image(height * pitch); + int v = 0; for (int y = 0; y < height; y++) {