# HG changeset patch # User Sebastien Jodogne # Date 1484914505 -3600 # Node ID 16b8e1cc9bbfeec5c2cd4e601e6259edec5a0d85 # Parent 82357198e5e66d765b0abe14de7211c958f5900d Fix issue #30: Bad colorspace if using OpenSlide diff -r 82357198e5e6 -r 16b8e1cc9bbf Framework/Inputs/OpenSlideLibrary.cpp --- a/Framework/Inputs/OpenSlideLibrary.cpp Wed Jan 04 17:02:38 2017 +0100 +++ b/Framework/Inputs/OpenSlideLibrary.cpp Fri Jan 20 13:15:05 2017 +0100 @@ -191,7 +191,7 @@ CheckLevel(level); // Create a new image, with minimal pitch so as to be compatible with OpenSlide API - std::auto_ptr region(new Orthanc::Image(Orthanc::PixelFormat_RGBA32, width, height, true)); + std::auto_ptr region(new Orthanc::Image(Orthanc::PixelFormat_BGRA32, width, height, true)); if (region->GetWidth() != 0 && region->GetHeight() != 0) diff -r 82357198e5e6 -r 16b8e1cc9bbf NEWS --- a/NEWS Wed Jan 04 17:02:38 2017 +0100 +++ b/NEWS Fri Jan 20 13:15:05 2017 +0100 @@ -1,6 +1,8 @@ Pending changes in the mainline =============================== +* Fix issue #30: Bad colorspace if using OpenSlide + Version 0.3 (2016/12/23) ======================== diff -r 82357198e5e6 -r 16b8e1cc9bbf Resources/Orthanc/Core/Images/ImageProcessing.cpp --- a/Resources/Orthanc/Core/Images/ImageProcessing.cpp Wed Jan 04 17:02:38 2017 +0100 +++ b/Resources/Orthanc/Core/Images/ImageProcessing.cpp Fri Jan 20 13:15:05 2017 +0100 @@ -458,6 +458,26 @@ return; } + if (target.GetFormat() == PixelFormat_RGB24 && + source.GetFormat() == PixelFormat_BGRA32) + { + for (unsigned int y = 0; y < source.GetHeight(); y++) + { + const uint8_t* p = reinterpret_cast(source.GetConstRow(y)); + uint8_t* q = reinterpret_cast(target.GetRow(y)); + for (unsigned int x = 0; x < source.GetWidth(); x++) + { + q[0] = p[2]; + q[1] = p[1]; + q[2] = p[0]; + p += 4; + q += 3; + } + } + + return; + } + if (target.GetFormat() == PixelFormat_RGBA32 && source.GetFormat() == PixelFormat_RGB24) {