Mercurial > hg > orthanc
annotate Plugins/Samples/GdcmDecoder/OrthancImageWrapper.cpp @ 3858:3ab2d48c8f69 c-get
integration mainline->c-get
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 21 Apr 2020 16:37:25 +0200 |
parents | 94f4a18a79cc |
children |
rev | line source |
---|---|
1834 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1834 | 4 * Department, University Hospital of Liege, Belgium |
3640
94f4a18a79cc
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
1834 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU General Public License as | |
9 * published by the Free Software Foundation, either version 3 of the | |
10 * License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #include "OrthancImageWrapper.h" | |
23 | |
24 #include <stdexcept> | |
25 | |
26 namespace OrthancPlugins | |
27 { | |
28 OrthancImageWrapper::OrthancImageWrapper(OrthancPluginContext* context, | |
29 OrthancPluginPixelFormat format, | |
30 uint32_t width, | |
31 uint32_t height) : | |
1840
859224214616
simplification of the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1836
diff
changeset
|
32 context_(context) |
1834 | 33 { |
34 image_ = OrthancPluginCreateImage(context_, format, width, height); | |
35 if (image_ == NULL) | |
36 { | |
37 throw std::runtime_error("Cannot create an image"); | |
38 } | |
39 } | |
40 | |
41 | |
1836 | 42 OrthancImageWrapper::OrthancImageWrapper(OrthancPluginContext* context, |
1840
859224214616
simplification of the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1836
diff
changeset
|
43 OrthancPluginImage* image) : |
1836 | 44 context_(context), |
1840
859224214616
simplification of the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1836
diff
changeset
|
45 image_(image) |
1836 | 46 { |
1842
697ae8d0e287
better handling of ordered-slices
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1840
diff
changeset
|
47 if (image_ == NULL) |
697ae8d0e287
better handling of ordered-slices
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1840
diff
changeset
|
48 { |
697ae8d0e287
better handling of ordered-slices
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1840
diff
changeset
|
49 throw std::runtime_error("Invalid image returned by the core of Orthanc"); |
697ae8d0e287
better handling of ordered-slices
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1840
diff
changeset
|
50 } |
1836 | 51 } |
52 | |
53 | |
54 | |
1834 | 55 OrthancImageWrapper::~OrthancImageWrapper() |
56 { | |
57 if (image_ != NULL) | |
58 { | |
59 OrthancPluginFreeImage(context_, image_); | |
60 } | |
61 } | |
62 | |
63 | |
64 OrthancPluginImage* OrthancImageWrapper::Release() | |
65 { | |
66 OrthancPluginImage* tmp = image_; | |
67 image_ = NULL; | |
68 return tmp; | |
69 } | |
70 | |
71 | |
72 uint32_t OrthancImageWrapper::GetWidth() | |
73 { | |
74 return OrthancPluginGetImageWidth(context_, image_); | |
75 } | |
76 | |
77 | |
78 uint32_t OrthancImageWrapper::GetHeight() | |
79 { | |
80 return OrthancPluginGetImageHeight(context_, image_); | |
81 } | |
82 | |
83 | |
84 uint32_t OrthancImageWrapper::GetPitch() | |
85 { | |
86 return OrthancPluginGetImagePitch(context_, image_); | |
87 } | |
88 | |
89 | |
90 OrthancPluginPixelFormat OrthancImageWrapper::GetFormat() | |
91 { | |
92 return OrthancPluginGetImagePixelFormat(context_, image_); | |
93 } | |
94 | |
95 | |
96 char* OrthancImageWrapper::GetBuffer() | |
97 { | |
98 return reinterpret_cast<char*>(OrthancPluginGetImageBuffer(context_, image_)); | |
99 } | |
100 } |