Mercurial > hg > orthanc-wsi
diff Framework/Outputs/HierarchicalTiffWriter.cpp @ 170:cea9a4701fce
Support of grayscale images
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 02 Aug 2019 15:31:19 +0200 |
parents | 605247fc8758 |
children | e3cbf890b588 |
line wrap: on
line diff
--- a/Framework/Outputs/HierarchicalTiffWriter.cpp Fri Jul 12 12:53:26 2019 +0200 +++ b/Framework/Outputs/HierarchicalTiffWriter.cpp Fri Aug 02 15:31:19 2019 +0200 @@ -160,7 +160,7 @@ switch (pixelFormat) { case Orthanc::PixelFormat_Grayscale8: - if (numberOfComponents != 3) + if (numberOfComponents != 1) { LOG(WARNING) << "The source image does not contain a grayscale image as expected"; } @@ -302,6 +302,23 @@ break; } + case Orthanc::PixelFormat_Grayscale8: + { + uint16_t samplesPerPixel = 1; + uint16_t bpp = 8; + uint16_t photometric = PHOTOMETRIC_MINISBLACK; + + if (TIFFSetField(tiff_, TIFFTAG_SAMPLESPERPIXEL, samplesPerPixel) != 1 || + TIFFSetField(tiff_, TIFFTAG_PHOTOMETRIC, photometric) != 1 || + TIFFSetField(tiff_, TIFFTAG_BITSPERSAMPLE, bpp) != 1) + { + Close(); + throw Orthanc::OrthancException(Orthanc::ErrorCode_CannotWriteFile); + } + + break; + } + default: throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); }