Mercurial > hg > orthanc
annotate OrthancServer/Plugins/Samples/CustomImageDecoder/Plugin.cpp @ 5285:bb07c12e3472
re-enabled the old NormalizeIdentifier code
author | Alain Mazy <am@osimis.io> |
---|---|
date | Mon, 24 Apr 2023 18:11:13 +0200 |
parents | 0ea402b4d901 |
children | 48b8dae6dc77 |
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 |
5185
0ea402b4d901
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4870
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
0ea402b4d901
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4870
diff
changeset
|
6 * Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
1828
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * This program is free software: you can redistribute it and/or |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * 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
|
10 * published by the Free Software Foundation, either version 3 of the |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * License, or (at your option) any later version. |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * 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
|
14 * WITHOUT ANY WARRANTY; without even the implied warranty of |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * General Public License for more details. |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * 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
|
19 * 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
|
20 **/ |
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 #include <orthanc/OrthancCPlugin.h> |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 static OrthancPluginContext* context_ = NULL; |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 |
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 static OrthancPluginErrorCode DecodeImageCallback(OrthancPluginImage** target, |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 const void* dicom, |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 const uint32_t size, |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 uint32_t frameIndex) |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 { |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 *target = OrthancPluginCreateImage(context_, OrthancPluginPixelFormat_RGB24, 512, 512); |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 memset(OrthancPluginGetImageBuffer(context_, *target), 128, |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 OrthancPluginGetImageHeight(context_, *target) * OrthancPluginGetImagePitch(context_, *target)); |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 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
|
39 } |
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 extern "C" |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 { |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* c) |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 { |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 context_ = c; |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 /* Check the version of the Orthanc core */ |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 if (OrthancPluginCheckVersion(c) == 0) |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 { |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 char info[1024]; |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 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
|
53 context_->orthancVersion, |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER, |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER, |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER); |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 OrthancPluginLogError(context_, info); |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 return -1; |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 } |
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 OrthancPluginRegisterDecodeImageCallback(context_, DecodeImageCallback); |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 return 0; |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 } |
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 ORTHANC_PLUGINS_API void OrthancPluginFinalize() |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 { |
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 ORTHANC_PLUGINS_API const char* OrthancPluginGetName() |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 { |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 return "custom-image-decoder"; |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 } |
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 ORTHANC_PLUGINS_API const char* OrthancPluginGetVersion() |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 { |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 return "0.0"; |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 } |
a71d74987090
sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 } |