Mercurial > hg > orthanc-wsi
diff ViewerPlugin/RawTile.cpp @ 277:ac1508b438b1 iiif
support of "Accept" header in /wsi/tiles/{id}/{z}/{x}/{y}
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 12 Jul 2023 16:14:19 +0200 |
parents | ef8a673b5fb9 |
children | 7020852a8fa9 |
line wrap: on
line diff
--- a/ViewerPlugin/RawTile.cpp Wed Jul 12 14:51:46 2023 +0200 +++ b/ViewerPlugin/RawTile.cpp Wed Jul 12 16:14:19 2023 +0200 @@ -39,6 +39,25 @@ namespace OrthancWSI { + static ImageCompression Convert(Orthanc::MimeType type) + { + switch (type) + { + case Orthanc::MimeType_Png: + return ImageCompression_Png; + + case Orthanc::MimeType_Jpeg: + return ImageCompression_Jpeg; + + case Orthanc::MimeType_Jpeg2000: + return ImageCompression_Jpeg2000; + + default: + throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); + } + } + + Orthanc::ImageAccessor* RawTile::DecodeInternal() { switch (compression_) @@ -82,30 +101,11 @@ } } - void RawTile::EncodeInternal(std::string& encoded, const Orthanc::ImageAccessor& decoded, Orthanc::MimeType encoding) { - switch (encoding) - { - case Orthanc::MimeType_Png: - { - Orthanc::PngWriter writer; - Orthanc::IImageWriter::WriteToMemory(writer, encoded, decoded); - break; - } - - case Orthanc::MimeType_Jpeg: - { - Orthanc::JpegWriter writer; - Orthanc::IImageWriter::WriteToMemory(writer, encoded, decoded); - break; - } - - default: - throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); - } + ImageToolbox::EncodeTile(encoded, decoded, Convert(encoding), 90 /* only used for JPEG */); }