Mercurial > hg > orthanc
diff Plugins/Engine/OrthancPlugins.cpp @ 1604:1f5d6a2f9638
JpegReader
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 01 Sep 2015 14:57:13 +0200 |
parents | 905b4db3092b |
children | fd0464ce1962 |
line wrap: on
line diff
--- a/Plugins/Engine/OrthancPlugins.cpp Tue Sep 01 13:08:41 2015 +0200 +++ b/Plugins/Engine/OrthancPlugins.cpp Tue Sep 01 14:57:13 2015 +0200 @@ -44,6 +44,7 @@ #include "../../Core/Compression/GzipCompressor.h" #include "../../Core/ImageFormats/PngReader.h" #include "../../Core/ImageFormats/PngWriter.h" +#include "../../Core/ImageFormats/JpegReader.h" #include "../../Core/ImageFormats/JpegWriter.h" #include <boost/regex.hpp> @@ -1063,22 +1064,29 @@ { const _OrthancPluginUncompressImage& p = *reinterpret_cast<const _OrthancPluginUncompressImage*>(parameters); + std::auto_ptr<ImageAccessor> image; + switch (p.format) { case OrthancPluginImageFormat_Png: { - std::auto_ptr<PngReader> image(new PngReader); - image->ReadFromMemory(p.data, p.size); - *(p.target) = reinterpret_cast<OrthancPluginImage*>(image.release()); - return; + image.reset(new PngReader); + reinterpret_cast<PngReader&>(*image).ReadFromMemory(p.data, p.size); + break; } case OrthancPluginImageFormat_Jpeg: - // TODO + { + image.reset(new JpegReader); + reinterpret_cast<JpegReader&>(*image).ReadFromMemory(p.data, p.size); + break; + } default: throw OrthancException(ErrorCode_ParameterOutOfRange); } + + *(p.target) = reinterpret_cast<OrthancPluginImage*>(image.release()); } @@ -1098,8 +1106,12 @@ } case OrthancPluginImageFormat_Jpeg: - // TODO - //writer.SetQuality(p.quality); + { + JpegWriter writer; + writer.SetQuality(p.quality); + writer.WriteToMemory(compressed, p.width, p.height, p.pitch, Convert(p.pixelFormat), p.buffer); + break; + } default: throw OrthancException(ErrorCode_ParameterOutOfRange);