comparison Plugins/Samples/CustomImageDecoder/Plugin.cpp @ 1828:a71d74987090

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