Mercurial > hg > orthanc-stone
annotate Framework/Viewport/CairoSurface.h @ 309:14ef1227120f am-callable-and-promise
web services: better handling of failures
author | am@osimis.io |
---|---|
date | Fri, 28 Sep 2018 15:02:43 +0200 |
parents | 5412adf19980 |
children | ce48c3b3b0e9 3a4ca166fafa |
rev | line source |
---|---|
0 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
134
4cff7b1ed31d
upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
47 | 8 * modify it under the terms of the GNU Affero General Public License |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
0 | 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 | |
47 | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
0 | 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 **/ | |
20 | |
21 | |
22 #pragma once | |
23 | |
212
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
24 #include <Core/Images/ImageAccessor.h> |
0 | 25 |
26 #include <boost/noncopyable.hpp> | |
27 #include <cairo.h> | |
28 | |
29 namespace OrthancStone | |
30 { | |
31 class CairoSurface : public boost::noncopyable | |
32 { | |
33 private: | |
34 cairo_surface_t* surface_; | |
35 unsigned int width_; | |
36 unsigned int height_; | |
37 unsigned int pitch_; | |
38 void* buffer_; | |
39 | |
40 void Release(); | |
41 | |
42 void Allocate(unsigned int width, | |
43 unsigned int height); | |
44 | |
45 public: | |
46 CairoSurface() : | |
47 surface_(NULL) | |
48 { | |
49 Allocate(0, 0); | |
50 } | |
51 | |
52 CairoSurface(unsigned int width, | |
53 unsigned int height) : | |
54 surface_(NULL) | |
55 { | |
56 Allocate(width, height); | |
57 } | |
58 | |
59 CairoSurface(Orthanc::ImageAccessor& accessor); | |
60 | |
61 ~CairoSurface() | |
62 { | |
63 Release(); | |
64 } | |
65 | |
66 void SetSize(unsigned int width, | |
67 unsigned int height); | |
68 | |
69 void Copy(const CairoSurface& other); | |
70 | |
71 unsigned int GetWidth() const | |
72 { | |
73 return width_; | |
74 } | |
75 | |
76 unsigned int GetHeight() const | |
77 { | |
78 return height_; | |
79 } | |
80 | |
81 unsigned int GetPitch() const | |
82 { | |
83 return pitch_; | |
84 } | |
85 | |
86 const void* GetBuffer() const | |
87 { | |
88 return buffer_; | |
89 } | |
90 | |
91 void* GetBuffer() | |
92 { | |
93 return buffer_; | |
94 } | |
95 | |
96 cairo_surface_t* GetObject() | |
97 { | |
98 return surface_; | |
99 } | |
100 | |
101 Orthanc::ImageAccessor GetConstAccessor() const; | |
102 | |
103 Orthanc::ImageAccessor GetAccessor(); | |
104 }; | |
105 } |