Mercurial > hg > orthanc-wsi
diff ViewerPlugin/RawTile.cpp @ 276:ef8a673b5fb9 iiif
clarification of RawTile::Answer()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 12 Jul 2023 14:51:46 +0200 |
parents | c72fbdecdc38 |
children | ac1508b438b1 |
line wrap: on
line diff
--- a/ViewerPlugin/RawTile.cpp Wed Jul 12 12:35:04 2023 +0200 +++ b/ViewerPlugin/RawTile.cpp Wed Jul 12 14:51:46 2023 +0200 @@ -85,9 +85,9 @@ void RawTile::EncodeInternal(std::string& encoded, const Orthanc::ImageAccessor& decoded, - Orthanc::MimeType transcodingType) + Orthanc::MimeType encoding) { - switch (transcodingType) + switch (encoding) { case Orthanc::MimeType_Png: { @@ -128,22 +128,17 @@ void RawTile::Answer(OrthancPluginRestOutput* output, - Orthanc::MimeType transcodingType) + Orthanc::MimeType encoding) { - if (compression_ == ImageCompression_Jpeg) + if ((compression_ == ImageCompression_Jpeg && encoding == Orthanc::MimeType_Jpeg) || + (compression_ == ImageCompression_Jpeg2000 && encoding == Orthanc::MimeType_Jpeg2000)) { - // The tile is already a JPEG image. In such a case, we can - // serve it as such, because any Web browser can handle JPEG. + // No transcoding is needed, the tile can be served as such OrthancPluginAnswerBuffer(OrthancPlugins::GetGlobalContext(), output, tile_.c_str(), - tile_.size(), Orthanc::EnumerationToString(Orthanc::MimeType_Jpeg)); + tile_.size(), Orthanc::EnumerationToString(encoding)); } else { - // This is a lossless frame (coming from a JPEG2000 or an - // uncompressed DICOM instance), which is not a DICOM-JPEG - // instance. We need to decompress the raw tile, then transcode - // it to the PNG/JPEG, depending on the "transcodingType". - std::string transcoded; { @@ -151,11 +146,11 @@ Orthanc::Semaphore::Locker locker(*transcoderSemaphore_); std::unique_ptr<Orthanc::ImageAccessor> decoded(DecodeInternal()); - EncodeInternal(transcoded, *decoded, transcodingType); + EncodeInternal(transcoded, *decoded, encoding); } OrthancPluginAnswerBuffer(OrthancPlugins::GetGlobalContext(), output, transcoded.c_str(), - transcoded.size(), Orthanc::EnumerationToString(transcodingType)); + transcoded.size(), Orthanc::EnumerationToString(encoding)); } } @@ -169,10 +164,10 @@ void RawTile::Encode(std::string& encoded, const Orthanc::ImageAccessor& decoded, - Orthanc::MimeType transcodingType) + Orthanc::MimeType encoding) { Orthanc::Semaphore::Locker locker(*transcoderSemaphore_); - EncodeInternal(encoded, decoded, transcodingType); + EncodeInternal(encoded, decoded, encoding); }