Mercurial > hg > orthanc
annotate OrthancServer/Plugins/Samples/CustomImageDecoder/Plugin.cpp @ 5640:f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 30 May 2024 21:19:57 +0200 |
parents | 48b8dae6dc77 |
children |
rev | line source |
---|---|
1828
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
a71d74987090
sample plugin: CustomImageDecoder
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 |
1828
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
5640
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
1828
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * This program is free software: you can redistribute it and/or |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * modify it under the terms of the GNU General Public License as |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * published by the Free Software Foundation, either version 3 of the |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * License, or (at your option) any later version. |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * This program is distributed in the hope that it will be useful, but |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * WITHOUT ANY WARRANTY; without even the implied warranty of |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * General Public License for more details. |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * You should have received a copy of the GNU General Public License |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 **/ |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 #include <orthanc/OrthancCPlugin.h> |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 static OrthancPluginContext* context_ = NULL; |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 static OrthancPluginErrorCode DecodeImageCallback(OrthancPluginImage** target, |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 const void* dicom, |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 const uint32_t size, |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 uint32_t frameIndex) |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 { |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 *target = OrthancPluginCreateImage(context_, OrthancPluginPixelFormat_RGB24, 512, 512); |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 memset(OrthancPluginGetImageBuffer(context_, *target), 128, |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 OrthancPluginGetImageHeight(context_, *target) * OrthancPluginGetImagePitch(context_, *target)); |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 return OrthancPluginDrawText(context_, *target, 0, "Hello world", 100, 50, 255, 0, 0); |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 } |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 extern "C" |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 { |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* c) |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 { |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 context_ = c; |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 /* Check the version of the Orthanc core */ |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 if (OrthancPluginCheckVersion(c) == 0) |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 { |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 char info[1024]; |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 sprintf(info, "Your version of Orthanc (%s) must be above %d.%d.%d to run this plugin", |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 context_->orthancVersion, |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER, |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER, |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER); |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 OrthancPluginLogError(context_, info); |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 return -1; |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 } |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 OrthancPluginRegisterDecodeImageCallback(context_, DecodeImageCallback); |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 return 0; |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 } |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 ORTHANC_PLUGINS_API void OrthancPluginFinalize() |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 { |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 } |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 ORTHANC_PLUGINS_API const char* OrthancPluginGetName() |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 { |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 return "custom-image-decoder"; |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 } |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 ORTHANC_PLUGINS_API const char* OrthancPluginGetVersion() |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 { |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 return "0.0"; |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 } |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 } |