Mercurial > hg > orthanc
annotate Plugins/Samples/AutomatedJpeg2kCompression/Plugin.cpp @ 1977:ad95331c526a
trace log of http headers
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 15 Apr 2016 10:47:53 +0200 |
parents | b1291df2f780 |
children | a3a65de1840f |
rev | line source |
---|---|
1816
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1816
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 * |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * This program is free software: you can redistribute it and/or |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * modify it under the terms of the GNU General Public License as |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * published by the Free Software Foundation, either version 3 of the |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * License, or (at your option) any later version. |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * This program is distributed in the hope that it will be useful, but |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * WITHOUT ANY WARRANTY; without even the implied warranty of |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * General Public License for more details. |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * You should have received a copy of the GNU General Public License |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 **/ |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 #include <orthanc/OrthancCPlugin.h> |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 #include <string> |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 static OrthancPluginContext* context_ = NULL; |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 static bool ReadFile(std::string& result, |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 const std::string& path) |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 { |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 OrthancPluginMemoryBuffer tmp; |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 if (OrthancPluginReadFile(context_, &tmp, path.c_str()) == OrthancPluginErrorCode_Success) |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 { |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 result.assign(reinterpret_cast<const char*>(tmp.data), tmp.size); |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 OrthancPluginFreeMemoryBuffer(context_, &tmp); |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 return true; |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 } |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 else |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 { |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 return false; |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 } |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 } |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 OrthancPluginErrorCode OnStoredCallback(OrthancPluginDicomInstance* instance, |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 const char* instanceId) |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 { |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 char buffer[1024]; |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 sprintf(buffer, "Just received a DICOM instance of size %d and ID %s from origin %d (AET %s)", |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 (int) OrthancPluginGetInstanceSize(context_, instance), instanceId, |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 OrthancPluginGetInstanceOrigin(context_, instance), |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 OrthancPluginGetInstanceRemoteAet(context_, instance)); |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 OrthancPluginLogInfo(context_, buffer); |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 if (OrthancPluginGetInstanceOrigin(context_, instance) == OrthancPluginInstanceOrigin_Plugin) |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 { |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 // Do not compress twice the same file |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 return OrthancPluginErrorCode_Success; |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 } |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 // Write the uncompressed DICOM content to some temporary file |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 std::string uncompressed = "uncompressed-" + std::string(instanceId) + ".dcm"; |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 OrthancPluginErrorCode error = OrthancPluginWriteFile(context_, uncompressed.c_str(), |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 OrthancPluginGetInstanceData(context_, instance), |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 OrthancPluginGetInstanceSize(context_, instance)); |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 if (error) |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 { |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 return error; |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 } |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 // Remove the original DICOM instance |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 std::string uri = "/instances/" + std::string(instanceId); |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 error = OrthancPluginRestApiDelete(context_, uri.c_str()); |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 if (error) |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 { |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 return error; |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 } |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 // Path to the temporary file that will contain the compressed DICOM content |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 std::string compressed = "compressed-" + std::string(instanceId) + ".dcm"; |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 // Compress to JPEG2000 using gdcm |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 std::string command1 = "gdcmconv --j2k " + uncompressed + " " + compressed; |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 // Generate a new SOPInstanceUID for the JPEG2000 file, as gdcmconv |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 // does not do this by itself |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 std::string command2 = "dcmodify --no-backup -gin " + compressed; |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 // Make the required system calls |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 system(command1.c_str()); |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 system(command2.c_str()); |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 // Read the result of the JPEG2000 compression |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 std::string j2k; |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 bool ok = ReadFile(j2k, compressed); |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 // Remove the two temporary files |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 remove(compressed.c_str()); |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 remove(uncompressed.c_str()); |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 if (!ok) |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 { |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 return OrthancPluginErrorCode_Plugin; |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 } |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 // Upload the JPEG2000 file through the REST API |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 OrthancPluginMemoryBuffer tmp; |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 if (OrthancPluginRestApiPost(context_, &tmp, "/instances", j2k.c_str(), j2k.size())) |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 { |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 ok = false; |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 } |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 if (ok) |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 { |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 OrthancPluginFreeMemoryBuffer(context_, &tmp); |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 } |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 return ok ? OrthancPluginErrorCode_Success : OrthancPluginErrorCode_Plugin; |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 } |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 extern "C" |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 { |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* c) |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 { |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 context_ = c; |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 /* Check the version of the Orthanc core */ |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 if (OrthancPluginCheckVersion(c) == 0) |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 { |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 char info[1024]; |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 sprintf(info, "Your version of Orthanc (%s) must be above %d.%d.%d to run this plugin", |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 context_->orthancVersion, |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER, |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER, |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER); |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 OrthancPluginLogError(context_, info); |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 return -1; |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 } |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 OrthancPluginRegisterOnStoredInstanceCallback(context_, OnStoredCallback); |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 return 0; |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 } |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 ORTHANC_PLUGINS_API void OrthancPluginFinalize() |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 { |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 } |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 ORTHANC_PLUGINS_API const char* OrthancPluginGetName() |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 { |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 return "sample-jpeg2k"; |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 } |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 ORTHANC_PLUGINS_API const char* OrthancPluginGetVersion() |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 { |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 return "0.0"; |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
161 } |
87c069c94ac9
plugin sample: automated jpeg2k compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
162 } |