Mercurial > hg > orthanc
comparison 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 |
comparison
equal
deleted
inserted
replaced
1603:905b4db3092b | 1604:1f5d6a2f9638 |
---|---|
42 #include "../../OrthancServer/ServerToolbox.h" | 42 #include "../../OrthancServer/ServerToolbox.h" |
43 #include "../../Core/Compression/ZlibCompressor.h" | 43 #include "../../Core/Compression/ZlibCompressor.h" |
44 #include "../../Core/Compression/GzipCompressor.h" | 44 #include "../../Core/Compression/GzipCompressor.h" |
45 #include "../../Core/ImageFormats/PngReader.h" | 45 #include "../../Core/ImageFormats/PngReader.h" |
46 #include "../../Core/ImageFormats/PngWriter.h" | 46 #include "../../Core/ImageFormats/PngWriter.h" |
47 #include "../../Core/ImageFormats/JpegReader.h" | |
47 #include "../../Core/ImageFormats/JpegWriter.h" | 48 #include "../../Core/ImageFormats/JpegWriter.h" |
48 | 49 |
49 #include <boost/regex.hpp> | 50 #include <boost/regex.hpp> |
50 | 51 |
51 namespace Orthanc | 52 namespace Orthanc |
1061 | 1062 |
1062 void OrthancPlugins::UncompressImage(const void* parameters) | 1063 void OrthancPlugins::UncompressImage(const void* parameters) |
1063 { | 1064 { |
1064 const _OrthancPluginUncompressImage& p = *reinterpret_cast<const _OrthancPluginUncompressImage*>(parameters); | 1065 const _OrthancPluginUncompressImage& p = *reinterpret_cast<const _OrthancPluginUncompressImage*>(parameters); |
1065 | 1066 |
1067 std::auto_ptr<ImageAccessor> image; | |
1068 | |
1066 switch (p.format) | 1069 switch (p.format) |
1067 { | 1070 { |
1068 case OrthancPluginImageFormat_Png: | 1071 case OrthancPluginImageFormat_Png: |
1069 { | 1072 { |
1070 std::auto_ptr<PngReader> image(new PngReader); | 1073 image.reset(new PngReader); |
1071 image->ReadFromMemory(p.data, p.size); | 1074 reinterpret_cast<PngReader&>(*image).ReadFromMemory(p.data, p.size); |
1072 *(p.target) = reinterpret_cast<OrthancPluginImage*>(image.release()); | 1075 break; |
1073 return; | |
1074 } | 1076 } |
1075 | 1077 |
1076 case OrthancPluginImageFormat_Jpeg: | 1078 case OrthancPluginImageFormat_Jpeg: |
1077 // TODO | 1079 { |
1080 image.reset(new JpegReader); | |
1081 reinterpret_cast<JpegReader&>(*image).ReadFromMemory(p.data, p.size); | |
1082 break; | |
1083 } | |
1078 | 1084 |
1079 default: | 1085 default: |
1080 throw OrthancException(ErrorCode_ParameterOutOfRange); | 1086 throw OrthancException(ErrorCode_ParameterOutOfRange); |
1081 } | 1087 } |
1088 | |
1089 *(p.target) = reinterpret_cast<OrthancPluginImage*>(image.release()); | |
1082 } | 1090 } |
1083 | 1091 |
1084 | 1092 |
1085 void OrthancPlugins::CompressImage(const void* parameters) | 1093 void OrthancPlugins::CompressImage(const void* parameters) |
1086 { | 1094 { |
1096 writer.WriteToMemory(compressed, p.width, p.height, p.pitch, Convert(p.pixelFormat), p.buffer); | 1104 writer.WriteToMemory(compressed, p.width, p.height, p.pitch, Convert(p.pixelFormat), p.buffer); |
1097 break; | 1105 break; |
1098 } | 1106 } |
1099 | 1107 |
1100 case OrthancPluginImageFormat_Jpeg: | 1108 case OrthancPluginImageFormat_Jpeg: |
1101 // TODO | 1109 { |
1102 //writer.SetQuality(p.quality); | 1110 JpegWriter writer; |
1111 writer.SetQuality(p.quality); | |
1112 writer.WriteToMemory(compressed, p.width, p.height, p.pitch, Convert(p.pixelFormat), p.buffer); | |
1113 break; | |
1114 } | |
1103 | 1115 |
1104 default: | 1116 default: |
1105 throw OrthancException(ErrorCode_ParameterOutOfRange); | 1117 throw OrthancException(ErrorCode_ParameterOutOfRange); |
1106 } | 1118 } |
1107 | 1119 |