Mercurial > hg > orthanc-wsi
diff Framework/Inputs/OpenSlidePyramid.cpp @ 318:8ad12abde290
sparse re-encoding with OpenSlide (notably for MIRAX format)
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 11 Sep 2024 16:11:16 +0200 |
parents | f611fb47d0e8 |
children | 0c34b6625c67 |
line wrap: on
line diff
--- a/Framework/Inputs/OpenSlidePyramid.cpp Wed Sep 11 13:43:39 2024 +0200 +++ b/Framework/Inputs/OpenSlidePyramid.cpp Wed Sep 11 16:11:16 2024 +0200 @@ -36,6 +36,7 @@ namespace OrthancWSI { void OpenSlidePyramid::ReadRegion(Orthanc::ImageAccessor& target, + bool& isEmpty, unsigned int level, unsigned int x, unsigned int y) @@ -51,6 +52,29 @@ const unsigned int width = source->GetWidth(); const unsigned int height = source->GetHeight(); + if (source->GetFormat() == Orthanc::PixelFormat_BGRA32) + { + isEmpty = true; + + for (unsigned int y = 0; y < height && isEmpty; y++) + { + const uint8_t* p = reinterpret_cast<const uint8_t*>(source->GetConstRow(y)); + for (unsigned int x = 0; x < width && isEmpty; x++) + { + if (p[3] != 0) + { + isEmpty = false; + } + + p += 4; + } + } + } + else + { + isEmpty = false; + } + if (target.GetFormat() == Orthanc::PixelFormat_RGB24 && source->GetFormat() == Orthanc::PixelFormat_BGRA32) {