Mercurial > hg > orthanc
annotate Plugins/Samples/GdcmDecoding/OrthancContext.cpp @ 2771:87a3a8c04d8a worklists
close old branch
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 17 Jul 2018 09:45:17 +0200 |
parents | 3d76e26b3865 |
children |
rev | line source |
---|---|
983
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1040
diff
changeset
|
3 * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics |
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1040
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
983
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 * |
1375
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
6 * This program is free software: you can redistribute it and/or |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
7 * modify it under the terms of the GNU General Public License as |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
8 * published by the Free Software Foundation, either version 3 of the |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
9 * License, or (at your option) any later version. |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
10 * |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
11 * This program is distributed in the hope that it will be useful, but |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
12 * WITHOUT ANY WARRANTY; without even the implied warranty of |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
14 * General Public License for more details. |
983
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * |
1375
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
16 * You should have received a copy of the GNU General Public License |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
983
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 **/ |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 #include "OrthancContext.h" |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 #include <stdexcept> |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 void OrthancContext::Check() |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 { |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 if (context_ == NULL) |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 { |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 throw std::runtime_error("The Orthanc plugin context is not initialized"); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 } |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 } |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 OrthancContext& OrthancContext::GetInstance() |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 { |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 static OrthancContext instance; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 return instance; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 } |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 void OrthancContext::ExtractGetArguments(Arguments& arguments, |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 const OrthancPluginHttpRequest& request) |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 { |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 Check(); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 arguments.clear(); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 for (uint32_t i = 0; i < request.getCount; i++) |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 { |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 arguments[request.getKeys[i]] = request.getValues[i]; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 } |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 } |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 void OrthancContext::LogError(const std::string& s) |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 { |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 Check(); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 OrthancPluginLogError(context_, s.c_str()); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 } |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 void OrthancContext::LogWarning(const std::string& s) |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 { |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 Check(); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 OrthancPluginLogWarning(context_, s.c_str()); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 } |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 void OrthancContext::LogInfo(const std::string& s) |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 { |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 Check(); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 OrthancPluginLogInfo(context_, s.c_str()); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 } |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 void OrthancContext::Register(const std::string& uri, |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 OrthancPluginRestCallback callback) |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 { |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 Check(); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 OrthancPluginRegisterRestCallback(context_, uri.c_str(), callback); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 } |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 void OrthancContext::GetDicomForInstance(std::string& result, |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 const std::string& instanceId) |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 { |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 Check(); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 OrthancPluginMemoryBuffer buffer; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 if (OrthancPluginGetDicomForInstance(context_, &buffer, instanceId.c_str())) |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 { |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 throw std::runtime_error("No DICOM instance with Orthanc ID: " + instanceId); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 } |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 if (buffer.size == 0) |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 { |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 result.clear(); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 } |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 else |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 { |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 result.assign(reinterpret_cast<char*>(buffer.data), buffer.size); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 } |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 OrthancPluginFreeMemoryBuffer(context_, &buffer); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 } |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 void OrthancContext::CompressAndAnswerPngImage(OrthancPluginRestOutput* output, |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 const Orthanc::ImageAccessor& accessor) |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 { |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 Check(); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 OrthancPluginPixelFormat format; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 switch (accessor.GetFormat()) |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 { |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 case Orthanc::PixelFormat_Grayscale8: |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 format = OrthancPluginPixelFormat_Grayscale8; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 break; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 case Orthanc::PixelFormat_Grayscale16: |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 format = OrthancPluginPixelFormat_Grayscale16; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 break; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 case Orthanc::PixelFormat_SignedGrayscale16: |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 format = OrthancPluginPixelFormat_SignedGrayscale16; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 break; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 case Orthanc::PixelFormat_RGB24: |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 format = OrthancPluginPixelFormat_RGB24; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 break; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 case Orthanc::PixelFormat_RGBA32: |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 format = OrthancPluginPixelFormat_RGBA32; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 break; |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 default: |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 throw std::runtime_error("Unsupported pixel format"); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 } |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 OrthancPluginCompressAndAnswerPngImage(context_, output, format, accessor.GetWidth(), |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 accessor.GetHeight(), accessor.GetPitch(), accessor.GetConstBuffer()); |
80d4f1618b33
Sample plugin to replace DCMTK by GDCM when decoding images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 } |
993
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
983
diff
changeset
|
143 |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
983
diff
changeset
|
144 |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
983
diff
changeset
|
145 |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
983
diff
changeset
|
146 void OrthancContext::Redirect(OrthancPluginRestOutput* output, |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
983
diff
changeset
|
147 const std::string& s) |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
983
diff
changeset
|
148 { |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
983
diff
changeset
|
149 Check(); |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
983
diff
changeset
|
150 OrthancPluginRedirect(context_, output, s.c_str()); |
501880d76474
improvements to GDCM plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
983
diff
changeset
|
151 } |