annotate Plugins/Samples/CustomImageDecoder/Plugin.cpp @ 2061:8856f15b3e02

disabling cache in ServeFolders
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 02 Jul 2016 11:16:25 +0200
parents b1291df2f780
children a3a65de1840f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1828
diff changeset
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
a71d74987090 sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 *
a71d74987090 sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * This program is free software: you can redistribute it and/or
a71d74987090 sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * 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
8 * published by the Free Software Foundation, either version 3 of the
a71d74987090 sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * License, or (at your option) any later version.
a71d74987090 sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 *
a71d74987090 sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * 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
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
a71d74987090 sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
a71d74987090 sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * General Public License for more details.
a71d74987090 sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 *
a71d74987090 sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * 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
17 * 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
18 **/
a71d74987090 sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19
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 #include <orthanc/OrthancCPlugin.h>
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 static OrthancPluginContext* context_ = NULL;
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
a71d74987090 sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 static OrthancPluginErrorCode DecodeImageCallback(OrthancPluginImage** target,
a71d74987090 sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 const void* dicom,
a71d74987090 sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 const uint32_t size,
a71d74987090 sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 uint32_t frameIndex)
a71d74987090 sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 {
a71d74987090 sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 *target = OrthancPluginCreateImage(context_, OrthancPluginPixelFormat_RGB24, 512, 512);
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 memset(OrthancPluginGetImageBuffer(context_, *target), 128,
a71d74987090 sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 OrthancPluginGetImageHeight(context_, *target) * OrthancPluginGetImagePitch(context_, *target));
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 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
37 }
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
a71d74987090 sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 extern "C"
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 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* 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 context_ = 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 /* Check the version of the Orthanc core */
a71d74987090 sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 if (OrthancPluginCheckVersion(c) == 0)
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 char info[1024];
a71d74987090 sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 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
51 context_->orthancVersion,
a71d74987090 sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER,
a71d74987090 sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER,
a71d74987090 sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER);
a71d74987090 sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 OrthancPluginLogError(context_, info);
a71d74987090 sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 return -1;
a71d74987090 sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 }
a71d74987090 sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58
a71d74987090 sample plugin: CustomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 OrthancPluginRegisterDecodeImageCallback(context_, DecodeImageCallback);
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 return 0;
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
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 ORTHANC_PLUGINS_API void OrthancPluginFinalize()
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
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 ORTHANC_PLUGINS_API const char* OrthancPluginGetName()
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 return "custom-image-decoder";
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
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 ORTHANC_PLUGINS_API const char* OrthancPluginGetVersion()
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 return "0.0";
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 }