comparison OrthancServer/ParsedDicomFile.cpp @ 2380:96b3ec054b69

reorganization in macros
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 29 Aug 2017 16:49:44 +0200
parents b7fba68747f6
children b8969010b534
comparison
equal deleted inserted replaced
2379:4900688827a8 2380:96b3ec054b69
80 #endif 80 #endif
81 81
82 #include "ParsedDicomFile.h" 82 #include "ParsedDicomFile.h"
83 83
84 #include "OrthancInitialization.h" 84 #include "OrthancInitialization.h"
85 #include "ServerToolbox.h"
86 #include "FromDcmtkBridge.h" 85 #include "FromDcmtkBridge.h"
87 #include "ToDcmtkBridge.h" 86 #include "ToDcmtkBridge.h"
88 #include "Internals/DicomFrameIndex.h" 87 #include "Internals/DicomFrameIndex.h"
89 #include "../Core/Images/JpegReader.h"
90 #include "../Core/Images/PngReader.h"
91 #include "../Core/Logging.h" 88 #include "../Core/Logging.h"
92 #include "../Core/OrthancException.h" 89 #include "../Core/OrthancException.h"
93 #include "../Core/Toolbox.h" 90 #include "../Core/Toolbox.h"
91
92 #if ORTHANC_ENABLE_JPEG == 1
93 # include "../Core/Images/JpegReader.h"
94 #endif
95
96 #if ORTHANC_ENABLE_PNG == 1
97 # include "../Core/Images/PngReader.h"
98 #endif
94 99
95 #include <list> 100 #include <list>
96 #include <limits> 101 #include <limits>
97 102
98 #include <boost/lexical_cast.hpp> 103 #include <boost/lexical_cast.hpp>
1014 return false; 1019 return false;
1015 } 1020 }
1016 1021
1017 Toolbox::ToLowerCase(mime); 1022 Toolbox::ToLowerCase(mime);
1018 1023
1019 if (mime == "image/png" || 1024 if (mime == "image/png")
1020 mime == "image/jpeg") 1025 {
1021 { 1026 #if ORTHANC_ENABLE_PNG == 1
1022 EmbedImage(mime, content); 1027 EmbedImage(mime, content);
1028 #else
1029 LOG(ERROR) << "Orthanc was compiled without support of PNG";
1030 throw OrthancException(ErrorCode_NotImplemented);
1031 #endif
1032 }
1033 else if (mime == "image/jpeg")
1034 {
1035 #if ORTHANC_ENABLE_JPEG == 1
1036 EmbedImage(mime, content);
1037 #else
1038 LOG(ERROR) << "Orthanc was compiled without support of JPEG";
1039 throw OrthancException(ErrorCode_NotImplemented);
1040 #endif
1023 } 1041 }
1024 else if (mime == "application/pdf") 1042 else if (mime == "application/pdf")
1025 { 1043 {
1026 EmbedPdf(content); 1044 EmbedPdf(content);
1027 } 1045 }
1042 throw OrthancException(ErrorCode_BadFileFormat); 1060 throw OrthancException(ErrorCode_BadFileFormat);
1043 } 1061 }
1044 } 1062 }
1045 1063
1046 1064
1065 #if (ORTHANC_ENABLE_JPEG == 1 && \
1066 ORTHANC_ENABLE_PNG == 1)
1047 void ParsedDicomFile::EmbedImage(const std::string& mime, 1067 void ParsedDicomFile::EmbedImage(const std::string& mime,
1048 const std::string& content) 1068 const std::string& content)
1049 { 1069 {
1050 if (mime == "image/png") 1070 if (mime == "image/png")
1051 { 1071 {
1062 else 1082 else
1063 { 1083 {
1064 throw OrthancException(ErrorCode_NotImplemented); 1084 throw OrthancException(ErrorCode_NotImplemented);
1065 } 1085 }
1066 } 1086 }
1087 #endif
1067 1088
1068 1089
1069 void ParsedDicomFile::EmbedImage(const ImageAccessor& accessor) 1090 void ParsedDicomFile::EmbedImage(const ImageAccessor& accessor)
1070 { 1091 {
1071 if (accessor.GetFormat() != PixelFormat_Grayscale8 && 1092 if (accessor.GetFormat() != PixelFormat_Grayscale8 &&