comparison Framework/Outputs/HierarchicalTiffWriter.cpp @ 167:605247fc8758

Fix issue #144 (OrthancWSIDicomizer PhotometricInterpretation)
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 12 Jul 2019 12:00:31 +0200
parents 6b8ccfc02051
children cea9a4701fce
comparison
equal deleted inserted replaced
166:f0dac1e8f736 167:605247fc8758
264 switch (GetPixelFormat()) 264 switch (GetPixelFormat())
265 { 265 {
266 case Orthanc::PixelFormat_RGB24: 266 case Orthanc::PixelFormat_RGB24:
267 { 267 {
268 uint16_t samplesPerPixel = 3; 268 uint16_t samplesPerPixel = 3;
269 uint16_t photometric = PHOTOMETRIC_YCBCR; 269 uint16_t photometric;
270 uint16_t planar = PLANARCONFIG_CONTIG; // Interleaved RGB 270 uint16_t planar = PLANARCONFIG_CONTIG; // Interleaved RGB
271 uint16_t bpp = 8; 271 uint16_t bpp = 8;
272 uint16_t subsampleHorizontal = 2; 272 uint16_t subsampleHorizontal = 2;
273 uint16_t subsampleVertical = 2; 273 uint16_t subsampleVertical = 2;
274 274
275 switch (photometric_)
276 {
277 case Orthanc::PhotometricInterpretation_YBRFull422:
278 photometric = PHOTOMETRIC_YCBCR;
279 break;
280
281 case Orthanc::PhotometricInterpretation_RGB:
282 photometric = PHOTOMETRIC_RGB;
283 break;
284
285 default:
286 throw Orthanc::OrthancException(
287 Orthanc::ErrorCode_ParameterOutOfRange,
288 "Unsupported photometric interpreation: " +
289 std::string(Orthanc::EnumerationToString(photometric_)));
290 }
291
275 if (TIFFSetField(tiff_, TIFFTAG_SAMPLESPERPIXEL, samplesPerPixel) != 1 || 292 if (TIFFSetField(tiff_, TIFFTAG_SAMPLESPERPIXEL, samplesPerPixel) != 1 ||
276 TIFFSetField(tiff_, TIFFTAG_PHOTOMETRIC, photometric) != 1 || 293 TIFFSetField(tiff_, TIFFTAG_PHOTOMETRIC, photometric) != 1 ||
277 TIFFSetField(tiff_, TIFFTAG_BITSPERSAMPLE, bpp) != 1 || 294 TIFFSetField(tiff_, TIFFTAG_BITSPERSAMPLE, bpp) != 1 ||
278 TIFFSetField(tiff_, TIFFTAG_PLANARCONFIG, planar) != 1 || 295 TIFFSetField(tiff_, TIFFTAG_PLANARCONFIG, planar) != 1 ||
279 TIFFSetField(tiff_, TIFFTAG_YCBCRSUBSAMPLING, subsampleHorizontal, subsampleVertical) != 1) 296 TIFFSetField(tiff_, TIFFTAG_YCBCRSUBSAMPLING, subsampleHorizontal, subsampleVertical) != 1)
381 398
382 HierarchicalTiffWriter::HierarchicalTiffWriter(const std::string& path, 399 HierarchicalTiffWriter::HierarchicalTiffWriter(const std::string& path,
383 Orthanc::PixelFormat pixelFormat, 400 Orthanc::PixelFormat pixelFormat,
384 ImageCompression compression, 401 ImageCompression compression,
385 unsigned int tileWidth, 402 unsigned int tileWidth,
386 unsigned int tileHeight) : 403 unsigned int tileHeight,
404 Orthanc::PhotometricInterpretation photometric) :
387 PyramidWriterBase(pixelFormat, compression, tileWidth, tileHeight), 405 PyramidWriterBase(pixelFormat, compression, tileWidth, tileHeight),
388 currentLevel_(0), 406 currentLevel_(0),
389 nextX_(0), 407 nextX_(0),
390 nextY_(0), 408 nextY_(0),
391 isFirst_(true) 409 isFirst_(true),
410 photometric_(photometric)
392 { 411 {
393 tiff_ = TIFFOpen(path.c_str(), "w"); 412 tiff_ = TIFFOpen(path.c_str(), "w");
394 if (tiff_ == NULL) 413 if (tiff_ == NULL)
395 { 414 {
396 throw Orthanc::OrthancException(Orthanc::ErrorCode_CannotWriteFile); 415 throw Orthanc::OrthancException(Orthanc::ErrorCode_CannotWriteFile);